?
Solved

Database diagram and Relationships

Posted on 2012-03-17
5
Medium Priority
?
541 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In this article, we’ll look at how to deploy ProxySQL.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

777 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