?
Solved

Database diagram and Relationships

Posted on 2012-03-17
5
Medium Priority
?
547 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
In this article, we’ll look at how to deploy ProxySQL.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

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