Solved

Database diagram and Relationships

Posted on 2012-03-17
5
530 Views
Last Modified: 2016-02-18
I have designed a SQL Server 2008R2 database, and have created a diagram. I am wondering whether creating relationships (drag-drop) between my tables in this diagram affects the tables and queries in any way, or is it just for visual purposes?

I know, this seems like a silly question, but I've discovered that I have still a whole lot to learn about designing databases, so your help will be appreciated, thanks.

Also, what is the difference between having the child as foreign key in the parent table, and the parent as foreign key in the child table, and also what effect does having both situations? Is there a standard for this?
0
Comment
Question by:mitdaniels
5 Comments
 
LVL 2

Expert Comment

by:JAruchamy
ID: 37733135
This is called normalization... It reduces redundancy of data. There are multiple forms of normalization... You have to read about it to understand....

http://www.informit.com/articles/article.aspx?p=1225693
http://support.microsoft.com/kb/283878
http://msdn.microsoft.com/en-us/library/ms191178.aspx
0
 

Author Comment

by:mitdaniels
ID: 37733175
I have normalized my tables to around 3NF, but perhaps my understanding or maybe the question could be phrased better.

I think my question relates more to the Relationships and how SSMS allows one to express those.
0
 
LVL 42

Accepted Solution

by:
dqmq earned 500 total points
ID: 37733192
The diagram does not affect queries and it has nothing to do with normalization.  

The relationships do illustrate foreign key constraints and if you draw one in the diagram, it creates one on the child table.  The FK constraint restricts the values that are allowed in the relevant columns to those in a row of the parent table.  That's called "referential integrity" and it's one of the fundamental forms of integrity in an SQL database.

The FK relationship defines which table is the parent.  By definition, the FK in the child table references a unique key in the parent table.  Always.

I think SQL Server allows a parent-child relationship in both directions, but it probably shouldn't. A FK means the parent must exist before you can insert the child.  So, if you have it both ways you cannot insert either row first unless one of the FK's is null.  OK, you might be able to conjure up a scenario where that makes some sense, but I rather expect there would always be a better design.
0
 

Author Closing Comment

by:mitdaniels
ID: 37733202
Thanks for a really good explanation.
0
 
LVL 1

Expert Comment

by:marrowyung
ID: 41471484
one thing sir,

 When drawing in SSMS, we add table there and if there are relationship between tables we can see it.

 But if we change anything, it will modify the table schema too, right ?

 What is the best tools to draw database diagram which for documentation only ?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Full Text Search string 5 33
Query Missing Money orders... 6 67
Slow SQL query 12 17
Change part of a string 2 16
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now