If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > weak entities and weak relationships???????

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-31-04, 23:54
il0postino il0postino is offline
Registered User
 
Join Date: Aug 2004
Posts: 3
weak entities and weak relationships???????

I am having trouble with weak entities and weak relationships.
The problem is this:
For example a database has a customer(table1) who places an order(orders=table2). The order consists of order details(table3) (1 detail per product, eg order of 4 of product X) and the product detail is linked to the table product(table4).
Now customer and product are strong entities(?). According to me Order and OrderDetail are weak entities(?).
Now The table order detail has all the keys in it which seems wrong......
(see attachment)
Attached Images
File Type: jpg ER.jpg (17.8 KB, 237 views)
File Type: jpg DSD.jpg (20.9 KB, 195 views)
Reply With Quote
  #2 (permalink)  
Old 09-01-04, 04:44
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
My understanding of the term "weak" entity is that it is an entity that cannot be uniquely identified without reference to another entity. Sicne an Order normally has a unique Order Number attribute, an Order is not a weak entity by that definition. Order Line is, because an Order Line cannot be uniquely identified without refering to the Order to which it belongs.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 09-01-04, 10:55
il0postino il0postino is offline
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks!
I think I am getting a better understanding of it all. Is it not so that you can choose to model entities as weak or strong. Surely orders are dependent on a customer but it is usually given a unique order number making it a strong entity. Couldn’t this also be done with order Line? The advantage of modeling order line as weak is that you cannot inadvertently enter two order lines, on the same order, with the same product.
Reply With Quote
  #4 (permalink)  
Old 09-01-04, 11:38
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Yes, you could do that with an order line surrogate key. But you would still need to define an alternate unique identifier on (order number, product code) if it was a rule that the same product cannot appear twice in an order. So I suppose it would still be "weak".

To be honest, in 15 years or so of entity modelling I have never used the terms "weak" and "strong". I know what they are because someone asked a question a year or two ago, and so I Googled the terms. I'm not sure what purpose it serves. As I implied above, you don't really "choose" to make an entity weak or strong, it just is or isn't - unless you deliberately subvert the business rules by not defining a unique constraint like (order number, product code) where one should exist, or perhaps make a strong entity like Customer weak by including another entity's ID in the unique identifier (e.g. Branch ID + sequence within branch).

Perhaps these terms feature more in a different ERD style than the one I use (Barker).
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #5 (permalink)  
Old 09-01-04, 13:25
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
The weak versus strong comes into play as you move toward the relational theory end of the database spectrum. It doesn't matter as much at the SQL level.

A strong entity can have predicates declared on the entity by itself. A weak entity needs to have all of the weak entities between it and it's nearest strong entity included within the predicate. To put that in more English terms, you can make a concrete statement about a strong entity, you can't make a concrete statement about a weak entity without including everything else that you need to get to a strong entity.

So in your example, you can state that an order exists because the order doesn't depend on anything else for it's existance... You can't be sure about the existance of an order line without refering to the order that includes that order line.

-PatP
Reply With Quote
  #6 (permalink)  
Old 09-01-04, 13:41
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
the terms i'm familiar with are identifying and non-identifying foreign keys

(thank you, ERwin, for all the cheerful memories and frequent nightmares)

an identifying foreign key is included within the primary key
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On