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
49
votes
3 answers
Adding an one-out-of-two not null constraint in postgresql
If I have a table in Postgresql:
create table Education (
id integer references Profiles(id),
finished YearValue not null,
started YearValue,
qualification text,
schoolName …

Jimmy
- 501
- 1
- 4
- 3
49
votes
4 answers
Django and postgresql schemas
I've been trying to solve this one all week, help very much appreciated.
I have various schemas in a postgres db and I would like to be able to map to them from within the same or across different django apps.
Some of the schemas are…

Spatial Digger
- 1,883
- 1
- 19
- 37
44
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
- 85,663
- 26
- 103
- 145
44
votes
4 answers
How to change schema of all tables, views and stored procedures in MSSQL
Recently we were having issues on our database server and after long efforts it was decided to change the database server. So we managed to restore the database on another server, change the connection string, etc. Everything was going as planned…

anar khalilov
- 16,993
- 9
- 47
- 62
44
votes
8 answers
SQL Query to search schema of all tables
I am working on a SQL Server 2008 Db that has many tables in it (around 200). Many of these tables contain a field by the name "CreatedDate". I am trying to identify all the table schema with this particular field.
Is there a SQL query to do this?

pencilslate
- 12,958
- 18
- 58
- 73
43
votes
11 answers
Dynamically changing schema in Entity Framework Core
UPD here is the way I solved the problem. Although it's likely to be not the best one, it worked for me.
I have an issue with working with EF Core. I want to separate data for different companies in my project's database via schema-mechanism. My…

user3272018
- 2,309
- 5
- 26
- 48
40
votes
5 answers
Import and export schema in cassandra
How to import and export schema from Cassandra or Cassandra cqlsh prompt?

vpggopal
- 437
- 1
- 4
- 3
39
votes
4 answers
MongoDB Diagram Design Tool
Planning a project using MongoDB and looking for a tool to map out the database.
Any suggestions of a database design tool similar to http://ondras.zarovi.cz/sql/demo/ that specifically supports MongoDB?
Thanks

Hutch
- 841
- 1
- 8
- 9
39
votes
5 answers
mongoengine - Ignore extra fields for schema validation
I am trying to query my database. Some records currently have extra fields that are not included in my model schema (by error, but I want to handle these cases). When I try to query the DB and transform the records into the schema, I get the…

Andrew
- 1,355
- 2
- 13
- 28
39
votes
5 answers
How to duplicate schemas in PostgreSQL
I have a database with schema public and schema_A. I need to create a new schema schema_b with the same structure than schema_a.
I found the function below, the problem is that it does not copy the foreign key constraints.
CREATE OR REPLACE…

Cristhian Boujon
- 4,060
- 13
- 51
- 90
39
votes
2 answers
Cannot create a new table after "DROP SCHEMA public"
Since I wanted to drop some tables and somebody suggested the below and I did it:
postgres=# drop schema public cascade;
DROP SCHEMA
postgres=# create schema public;
CREATE SCHEMA
Then I got problem when creating a new database, such as:
postgres=#…

user1342336
- 967
- 2
- 16
- 28
38
votes
4 answers
MongoDB Structure for message app
I am breaking my mind up thinking about a good document structure for handling a message app.
I basically need three (or four) types of objects:
The user (username, email, password, etc.)
The contacts list (containing different contacts or contacts…

dev.pus
- 7,919
- 13
- 37
- 51
37
votes
2 answers
Setting schema name for DbContext
I know how to set the schema for a table in my context but is there a way to set the default schema for all the tables in a context?
i.e.
[Schema = "Ordering"]
public class MyContext:DbContext
{
public MyContext()
:…

John S
- 7,909
- 21
- 77
- 145
36
votes
6 answers
Why use a 1-to-1 relationship in database design?
I am having a hard time trying to figure out when to use a 1-to-1 relationship in db design or if it is ever necessary.
If you can select only the columns you need in a query is there ever a point to break up a table into 1-to-1 relationships. I…

chobo
- 31,561
- 38
- 123
- 191
33
votes
4 answers
InfluxDB : single or multiple measurement
I'm a beginner with influxDB and after reading the Schema design documentation a question remain.
How to decide if you should use one measurement with multiple fields or multiple measurement with single field ?
I have multiple iot device which send…

grunk
- 14,718
- 15
- 67
- 108