Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Posts
    9

    Unanswered: Composite Primary Key

    I have an entity where its primary keys are composite keys, However i don't know how to implement it on Oracle Desiger - ERD ? Can u Help??

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Composite Primary Key

    In Designer's ERDs foreign keys are represented by relationships (not by attributes) and attributes are used for all other (non-FK) values.

    So suppose we have entities:

    Department:
    # ID
    * Name

    Employee:
    # ID
    * Name

    (# indicates that the attribute is part of the primary unique identifier)

    Now suppose we want to add another entity "Assignment" to represent a many:many relationship between Departments and Employees with Start and End Dates. The unique identifier of this is to be the combination of Department, Employee and Start Date. Here is the entity, without any UID as yet:

    Assignment:
    * Start Date
    * End Date

    We would then add relationships from Assignment to Department and Employee:

    1) Each Employee may be subject to one or more Assignments; each Assignment must be of one and only one Employee

    2) Each Department may be subject to one or more Assignments; each Assignment must be for one and only one Department

    On the ERD these relationships will look something like this:

    [Employee]- - - - -----< [Assignment] >------- - - - - [Department]

    Now we can add the primary UID information to Assignment. There are many ways to go about this, but this is one way:

    1) Select the entity Assignment on the ERD
    2) Open the Properties page for the entity (double click or select Edit/Properties etc)
    3) Select the UIDs tab
    4) From the "Candidate Attributes" list select Start Date
    5) From the "Candidate Relationships" list select "of Employee" and "for Department" (use control key when selecting multiple objects)
    6) Press the button with the "down" arrowhead and the selected attribute and relationships are listed in the "Unique Identifier Contents" pane.
    7) Press OK to return to the ERD

    The Assignment entitity will now show Start Date is part of the primary UID like this:

    Assignment:
    # Start Date
    * End Date

    And the relationships will be indicated as being part of the primary UID by a bar across the relationship end like this:

    [Employee]- - - - -----|< [Assignment] >|------- - - - - [Department]

    There you have it: an entity with a composite primary UID consisting of 1 attribute and 2 ("foreign key") relationships.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •