[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Database diagram and Relationships

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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

649 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