database-schema

Identifying relationship - many to many

牧云@^-^@ 提交于 2019-12-10 10:33:27
问题 I have made a small database for a daycare centre. I have been reading up on identifying and non-identifying relationships and am still a bit confused about the whole thing. I have been using MySQL Workbench to design the database. Now, the criterias for parents and children are that a Parent can have one or more Children and vice versa - ergo, the relationship between Parents and Children is a many-to-many. The best praktice to solve this (as I understand) is to make a third table - Parets

Schema for chat application using mongodb

佐手、 提交于 2019-12-10 10:07:15
问题 I am trying to build a schema for chat application in mongodb . I have 2 types of user models - Producer and Consumer . Producer and Consumer can have conversations with each other. My ultimate goal is to fetch all the conversations for any producer and consumer and show them in a list, just like all the messaging apps (eg Facebook) do. Here is the schema I have come up with: Producer: { _id: 123, 'name': "Sam" } Consumer:{ _id: 456, name: "Mark" } Conversation: { _id: 321, producerId: 123,

How to set up Primary Keys in a Relation?

最后都变了- 提交于 2019-12-10 09:57:02
问题 I wish to know how to correctly set up Primary Keys in a Relation . E.g. we have ER-diagram which contain elements: Key attributes Weak key attributes Identifying relationships Associative entities In order to translate it into Relational Model we should do some tricks. All elements above deal with Primary Keys of relations but they all are Natural Keys - so we can leave them as is or replace with Surrogate Keys . Consider some cases. Case 1 Key Attribute is a name - so it must be of type

Storing User Settings - anything wrong with using “Flags” or “Bits” instead of a bunch of bools?

不问归期 提交于 2019-12-10 02:36:42
问题 I'm designing the User Settings for my MVC application, and right now I have ~20 boolean settings that the user can toggle. Since every user will always have every setting, I was thinking about storing each setting as a boolean on the User table. Though this would become unwieldy as the application requirements grow. First question - is there anything wrong with having a ton of columns on your table in this situation? I then considered using Flags, and storing the settings as one bit each in

Creating a database with MySQL Workbench from existing schema/model

拈花ヽ惹草 提交于 2019-12-10 01:52:41
问题 I built a database schema (or Model?) with MySQL Workbench . I'd like to now make it into an actual database. I've seen Forward and Reverse engineer options and can't find a clear answer on if either are what I need. How can I turn this into an actual database? 回答1: This for mysql workbench version 6.0 and for exporting a schema . Select tab MySQL Model Select File->Export->Forward Engineer SQL Create Place a file name to be exported in the Output SQL Script File, choose your options, next

How to get a list of all tables in two different databases

随声附和 提交于 2019-12-10 01:04:40
问题 I'm trying to create a little SQL script (in SQL Server Management Studio) to get a list of all tables in two different databases. The goal is to find out which tables exist in both databases and which ones only exist in one of them. I have found various scripts on SO to list all the tables of one database, but so far I wasn't able to get a list of tables of multiple databases. So: is there a way to query SQL Server for all tables in a specific database, e.g. SELECT * FROM ... WHERE

SQL Server Database schema versioning and update

无人久伴 提交于 2019-12-09 19:01:14
问题 For my application I have to support update scenarios and the database might be affected. I want to be able to update from an old version to the newest without installing intermediate versions. E.g. Suppose I have version A (the oldest), B (intermediate) and C (new version). I want to be able to update version A straight to version C. For the application files this is simple, I just replace the old with the new ones. However for the database I do not wish to generate a SQL Script to change

What's the proper way to store this data in a MySQL schema?

假如想象 提交于 2019-12-09 16:28:47
问题 I have a movie in a MySQL database. A movie contains data attributes that will never change, such as the following: Barcode: 025192018626 Format: DVD Runtime: 121 min. Discs: 1 Title: 12 Monkeys Year: 1995 It's one single row in a table. But I want to give my user's complete customization over this information in case something is incorrect according to them or if they just want to modify how the data is displayed in some way. I don't care why, I just want to give my users an option to do

SQL Server 2008 - create database script (schema + data) with command-line

筅森魡賤 提交于 2019-12-09 09:53:07
问题 In SSMS when I click on the database "Tasks -> Generate Scripts", I get an output script. How do I do the same with a non-graphical tool? 回答1: The graphical tool is just a wrapper around the SMO classes that actually implement scripting, like the Scripter class. There is an example of scripting all tables in a database with SMO in MSDN: Scripting: //Connect to the local, default instance of SQL Server. { Server srv = default(Server); srv = new Server(); //Reference the AdventureWorks database

How can I find all columns that are filled with 100% nulls in my SQL Server database schema?

陌路散爱 提交于 2019-12-08 22:17:02
问题 Is there a SQL way to find out which columns in my schema are completely full of null values? There are some fields in a couple of tables that I know are not used by the application and will be dropped, but I wanted to see if there was an automated way/script to find this out across the whole database to find candidates for code review/possible removal. Running SQL Server 2005 on x86 if it matters. Thanks in advance! 回答1: create table #SuspectColumns ( TABLE_SCHEMA sysname, TABLE_NAME sysname