Solved

Database diagram and Relationships

Posted on 2012-03-17
5
535 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

840 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