Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2012
    Posts
    1

    Help With Entity Relation

    Hi everyone. First of all, yes this is a homework question. I've tried working it out myself but alas here I am.

    Anyway. here goes.

    I have these 3 entities. Passenger, Company, Payment

    ----------
    Passenger
    ----------
    CustomerNum(PK)
    DOB(PK)
    First_Name
    Last_Name
    Gender
    Street
    Zip

    ---------
    Company
    ---------
    CompanyNum(PK)
    Name
    Street
    Zip

    ---------
    Payment
    ---------
    TransactionNum(PK)
    Date(PK)
    Amount
    Method

    Basically a passenger makes a payment. Also a company makes a payment.
    But a payment can only be made by either a passenger or a company not both. How can i form that sort of relation? Is it possible?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,000
    do a search for supertype/subtype

    you need a supertype table (clients?) to which both passengers and companies belong as subtypes

    then relate payments to clients
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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