weak entity and its primary key

Posted on 2005-05-11
Medium Priority
Last Modified: 2008-01-09

   I know that for weak entity, we have to include the primary keys of the strong attribute as one of the weak entity's attribute. I would like to know if it is possible that the primary keys of the weak entity does not include the primary key of the strong entity which it is related to? Lets say in one question, the answer given was


Strong entity...
Table Orders
ID        int      Primary Key
OrderNum  varchar
OrderDate datetime

Table Items
ID        int      Primary Key
Desc      varchar

Table OrderDetail
OrderID   int      Foreign Key (references Order.ID)
ItemID    int      Foreign Key (references Item.ID)
Qty       int

So if I give a unique number lets say OrderDetail_id as the primary key, do I still need the OrderID and ItemID as one of the primary keys in the weak entity?
Question by:hongjun
LVL 44

Accepted Solution

Arthur_Wood earned 1000 total points
ID: 13976905
If you have a separate field (OrderDetail_ID) as the Primary Key of the OrderDetail table, then NO you would not also include OderID and ItemID as part of the primary Key.  Howver, you should create a Unique Index on the combination of OrderID and ItemID in that table, as it is not allowed to have multiple records with the SAME combination of OrderID and ItemID in the OrderDetail table.

LVL 33

Author Comment

ID: 13978476
Hey.. Arthur_Wood,

Thanks for your input. It was accidentally posted by a friend using my account without me logging off first.
As such, this question is closed now.


Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
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

807 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