Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

22 Posts

Posted - 04/24/2013 :  11:16:16  Show Profile  Reply with Quote
Please, I dont understand why weak entity cannot have a key ateribute!

If we have, f,e, , an example: a room can not exist without a building, but one building can have 0 to many rooms, does it mean that a room as a weak E cannot have key attribute?
Can U give me an example?
Many thanks!

Flowing Fount of Yak Knowledge

4614 Posts

Posted - 04/24/2013 :  12:01:08  Show Profile  Reply with Quote
I'm not sure if this is a strong example, but I think this is considered a Weak Entity..

Consider an order system. In many systems you have an Order (Header) and an Order Detail (or Line Item). The Order Detail doesn't make any sense without the Order itself. So the Order Detail (or Line Item) would be considered a Weak Entity becuase it needs the Order (Header) to (FK to Order) exist in order for you to have an Order Detail (Line Item) row.

Honestly, I wouldn't get hung up in classifications of entities. Just know there are Enties, Attributes and Relationships. Master that, and you'll do fine.

Edited by - Lamprey on 04/24/2013 12:04:15
Go to Top of Page

Aged Yak Warrior

549 Posts

Posted - 04/24/2013 :  12:40:47  Show Profile  Reply with Quote
I agree with Lamprey; it is all relative depending on how you design your data model.
For an attribute to be a key, it should be uniquely identifiable.
Here is another example, if you want to create a table containing information about your friends.
You may create a table like this:

CREATE TABLE dbo.Friends (
Name NVARCHAR(20),
Birthday Date,
CellPhone NVARCHAR(20),
With the following data:
Name	Birthday	         CellPhone
John 	Jan 2, 1996	1234566-0989
Phil	Aug 1, 1994	
John	Jun 1, 1995	1222566-0989
Andrew	Aug 1, 1994	1234566-0988

Since two friends have the same name, and two of them have the same birthday you cannot use either name or birthday as keys. Since Phil does not have a Cellphone you cannot use CellPhone as a key either.
In this case you can do couple of things to create a key;
You can combine Name, birthday and Cellphone together as a key, because it is unlikely that two friends will have the same name, birthday and cellphone number; together they should form a unique identifier. Or you may choose to add a new attribute to the table called ID and assign a unique number for each of your friends.

CREATE TABLE dbo.Friends (
Name NVARCHAR(20),
Birthday Date,
CellPhone NVARCHAR(20),
ID int

Name	Birthday	           CellPhone	ID
John 	Jan 2, 1996	1234566-0989	1
Phil	Aug 1, 1994		2
John	Jun 1, 1995	1222566-0989	3
Andrew	Aug 1, 1994	1234566-0988	4

You can read more on this topic at:

good luck
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000