weak entity and its primary key

Posted on 2005-05-11
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

    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

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
    This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now