A description of the structure of the database - including the structure of the tables, columns, constraints, views, etc, etc... that make up the database.Normally defined in the text, generally SQL in an RDBMS, the schema describes the complete blueprint for the database, defining everything about the database except that data itself.
Questions tagged [database-schema]
2931 questions
33
votes
2 answers
Rails 3. Creating a production database
How can I create a production database in Rails 3 and load a schema to it?
I tried the following approaches...
I.
rake db:create Rails.env='production' && rake db:schema:load Rails.env='production'
II.
# config/environment.rb
# Set the rails…

Shamaoke
- 6,222
- 8
- 34
- 40
33
votes
1 answer
Migrating ManyToManyField to null true, blank true, isn't recognized
I have made a model change from
standard = models.ManyToManyField(Standard)
to
standard = models.ManyToManyField(Standard, blank=True, null=True)
South schemamigration for this app doesn't recognize the change?
Similar to this question, which is…

npradeetw
- 358
- 1
- 3
- 7
32
votes
6 answers
Designing a SQL schema for a combination of many-to-many relationship (variations of products)
I hope the title is somewhat helpful. I'm using MySQL as my database
I am building a database of products and am not sure how to handle storing prices/SKU of variations of a product. A product may have unlimited variations, and each variation…

Zaki Aziz
- 3,592
- 11
- 43
- 61
30
votes
2 answers
Group output of SHOW COLUMNS into comma-delimited list
I am comparing database tables on a development server against a live server, looking for column name changes, new columns, and columns that have been dropped. I'd like to do something like this:
SELECT GROUP_CONCAT(Field) FROM (SHOW COLUMNS ON…

Chris Baker
- 49,926
- 12
- 96
- 115
30
votes
5 answers
Database table design for scheduling tasks
I want to be able to create schedules that can be executed based on a fixed date, repeated daily, repeated on a particular day of the week, repeated on a particular month of the year, repeated on a particular date every year, and repeated at a…

Orson
- 14,981
- 11
- 56
- 70
29
votes
2 answers
How can I handle different data types in an Entity-Attribute-Value design (e.g. single table with multiple columns or multiple tables per data type)?
I want to create a patient/sample metadata table using an entity-attribute-value (EAV) approach.
Question: How should I handle the varying column type of the value (e.g. string, numeric, or foreign key to dictionary table) based on the…

lebolo
- 2,120
- 4
- 29
- 44
29
votes
3 answers
Entity-Attribute-Value Table Design
I am currently designing a database structure for the products section of an ecommerce platform. It needs to be designed in such a way that makes it possible to sell an infinite number of different types of products with an infinite number of…

James Arnold
- 990
- 1
- 6
- 15
28
votes
3 answers
Doctrine schema update or Doctrine migrations
What are the practical advantages of Doctrine Migrations over just running a schema update?
Safety?
The orm:schema-tool:update command (doctrine:schema:update in Symfony) warns
This operation should not be executed in a production…

Tamlyn
- 22,122
- 12
- 111
- 127
27
votes
7 answers
Is shortening MongoDB property names worthwhile?
In mongodb docs the author mentions it's a good idea to shorten property names:
Use shorter field names.
and in an old blog post from how to node (it is offline by now April, 2022 edit)
....oft-reported issue with mongoDB is the
size of the data…

raam86
- 6,785
- 2
- 31
- 46
26
votes
1 answer
How to get current tenant when using Appartment gem in multi-tenancy Rails 4
How can I find out which tenant (schema) is the current one when Apartment was initialized according to request

Sergiy Seletskyy
- 16,236
- 7
- 69
- 80
26
votes
2 answers
Sequelize: Changing model schema on production
We're using the orm sequelize.js and have defined a model as such:
module.exports = function(sequelize, DataTypes) {
var Source = sequelize.define('Source', {
name: {
type: DataTypes.STRING,
allowNull: false,
…

Matt
- 5,547
- 23
- 82
- 121
25
votes
4 answers
Poll Database Schema
What is the best database schema for polls? Is one-to-many relationship good for this? I'm thinking about having two tables:
poll_questions
int id
varchar body
datetime created_at
datetime updated_at
poll_answers
int id
…

Richard Knop
- 81,041
- 149
- 392
- 552
25
votes
3 answers
MongoDB: remove unique constraint
I'm trying the "Develop a RESTful API Using Node.js With Express and Mongoose" example and I ran into a problem with the MongoDB Schema:
POST:
{ title: 'My Awesome T-shirt 2',
description: 'All about the details. Of course it\'s black.',
style:…

Stefan Ernst
- 2,781
- 4
- 25
- 34
24
votes
10 answers
Is there a way to get a schema of a database from within python?
I'm trying to find out a way to find the names of tables in a database(if any exist). I find that from a sqlite cli I can use:
>.tables
Then for the fields:
>PRAGMA TABLE_INFO(table_name)
This obviously doesn't work within python. Is there even…

tijko
- 7,599
- 11
- 44
- 64
23
votes
1 answer
Add constraint to existing SQLite table
I'm using SQLite, which doesn't support adding a constraint to an existing table.
So I can't do something like this (just as an example):
ALTER TABLE [Customer]
ADD CONSTRAINT specify_either_phone_or_email
CHECK (([Phone] IS NOT NULL) OR ([Email] IS…

grokky
- 8,537
- 20
- 62
- 96