Questions tagged [database-schema]

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.

2784 questions
89
votes
5 answers

mysqldump - Export structure only without autoincrement

I have a MySQL database and I am trying to find a way to export its structure only, without the auto increment values. mysqldump --no-data would almost do the job, but it keeps the auto_increment values. Is there any way to do it without using…
Paris
  • 5,473
  • 7
  • 28
  • 43
83
votes
3 answers

Good practices for designing monthly subscription system in database

I'd like to know how to design a monthly subscription software system in a database. These systems are broadly used all over internet, though I can't find lots of stuff about database design. In my case, these elements (and maybe some others I…
David D.
  • 8,377
  • 5
  • 49
  • 101
76
votes
4 answers

What is the purpose of the ConcurrencyStamp column in the AspNetUsers table in the new ASP.NET MVC 6 identity?

What is the purpose of the ConcurrencyStamp column in the AspNetUsers table in the new ASP.NET MVC 6 identity? This is the database schema of the AspNetUsers table: It is also there in the AspNetRoles table: As I remember it wasn't there in the…
74
votes
1 answer

Mysqldump: create column names for inserts when backing up

How do I instruct mysqldump to backup with column names in insert statements? In my case I didn’t a normal back up with insert sql’s resulting in LOCK TABLES `users` WRITE; /*!40000 ALTER TABLE `users` INSERT INTO `users` VALUES (1 structure. …
Quintin Par
  • 14,646
  • 27
  • 87
  • 142
70
votes
6 answers

Using multiple PostgreSQL schemas with Rails models

I have a PostgreSQL database for my Rails application. In the schema named 'public' the main Rails models tables are stored etc. I have created a 'discogs' schema which will have tables with names that are sometimes the same as in the 'public'…
Johan
  • 1,807
  • 5
  • 23
  • 27
68
votes
13 answers

How to find column names for all tables in all databases in SQL Server

I want to find all column names in all tables in all databases. Is there a query that can do that for me? The database is Microsoft SQL Server 2000.
Salman A
  • 229,425
  • 77
  • 398
  • 489
67
votes
4 answers

Is it OK to update a production database with EF migrations?

According to this blog post most companies using EF Migrations are supposedly not updating the database schema of production databases with EF migrations. Instead the blog post's author recommends to use Schema update scripts as part of the…
63
votes
10 answers

Should I use a single or multiple database setup for a multi-client application?

I am working on a PHP application that intends to ease company workflow and project management, let's say something like Basecamp and GoPlan. I am not sure on what the best approach is, database-wise. Should I use a single database and add…
Aron Rotteveel
  • 73,917
  • 17
  • 100
  • 128
48
votes
2 answers

How do I set the default schema for a user in MySQL

Is there a way to set a default schema for each user in MySQL and if so how? Where user x would default to schema y and user z would default to schema a.
Robert Louis Murphy
  • 1,498
  • 1
  • 15
  • 29
45
votes
4 answers

What mysql database tables and relationships would support a Q&A survey with conditional questions?

I'm working on a fairly simple survey system right now. The database schema is going to be simple: a Survey table, in a one-to-many relation with Question table, which is in a one-to-many relation with the Answer table and with the PossibleAnswers…
kender
  • 79,300
  • 24
  • 99
  • 144
45
votes
9 answers

What's better - many small tables or one big table?

I've got a database which will store profiles about individuals. These individuals have about 50 possible fields. Some are common things like, first name, last name, email, phone number. Others are things like hobbies, skills, interests Some are…
Mazatec
  • 10,573
  • 23
  • 65
  • 106
45
votes
14 answers

DB2 Query to retrieve all table names for a given schema

I'm just looking for a simple query to select all the table names for a given schema. For example, our DB has over 100 tables and I need to find any table that contains the sub-string “CUR”. I can use the like command once I have all the tables.
Ben
  • 2,149
  • 4
  • 26
  • 41
45
votes
7 answers

copy database structure without data in mysql (with empty tables)

Is there any way to copy database structure without data in MySQL, so the new database will be the same as it is copied from, but with empty tables. After getting some suggestions I tried the command, but I am getting syntax error, my username =…
Pramod
  • 2,644
  • 6
  • 27
  • 39
44
votes
9 answers

Differences between key, superkey, minimal superkey, candidate key and primary key

I'm new to MySQL, and I'm really confused about the different terms that I've encountered. I tried googling the answer but the results are really confusing and when I try and understand it just seems like they are the same thing. What exactly are…
Aaron
  • 1,879
  • 6
  • 27
  • 43
42
votes
5 answers

Is it possible to create a column with a UNIX_TIMESTAMP default in MySQL?

I'm trying to do this, but it seems like MySQL isn't allowing me. Is there a solution to this issue or am I expected to always include the function in my INSERT queries? CREATE TABLE foo( created INT NOT NULL DEFAULT UNIX_TIMESTAMP() ) I'm aware…
Kit Sunde
  • 32,665
  • 22
  • 111
  • 176