facebook

table relationships

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #294974 Reply

    David
    Member

    I am trying to learn Hibernate and have a db design question that seems to be holding me up. If I have an employee table, phone table and address table, what is the best way to define their relationships? I thought a simple OneToMany (employee to phones) and OneToOne (employee to address) would work but putting in an id column in the phone and address tables. However, if I want to have customers also use the same phone and address tables, that seems to break that model. It seems like phone and address do need to be in their own tables, but I would greatly appreciate any advice anyone with more database experience can throw my way.

    #294976 Reply

    Loyal Water
    Member

    sonoerin,
    I can’t help you much with this but I’m sure there would be other users on the forums who could pitch in with their advice.

    #295043 Reply

    David
    Member

    Perhaps I should phrase this differently to elicit some feedback….

    I am trying to have an address table that can be used by Employee, Customer, Business, etc. I can’t do a many-to-one because the address won’t know who it belongs to. I thought perhaps a lookup table would work, but I haven’t seen any examples that works across multiple tables, mostly just to join two tables.

    Does anyone know how to best join a single table with several others independtly? Of is it better just to have an address table for eah entity that could use it – EmployeeAddressTable, CustomerAddressTable, etc?

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: table relationships

You must be logged in to post in the forum log in