Data Modeling Help - Do I add another table, change existing table's usage, or something else?
        Posted  
        
            by StackOverflowNewbie
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by StackOverflowNewbie
        
        
        
        Published on 2010-06-02T08:25:10Z
        Indexed on 
            2010/06/02
            8:43 UTC
        
        
        Read the original article
        Hit count: 343
        
Assume I have the following tables and relationships:
Person
- Id (PK)
- Name
A Person can have 0 or more pets:
Pet
- Id (PK)
- PersonId (FK)
- Name
A person can have 0 or more attributes (e.g. age, height, weight):
PersonAttribute
_ Id (PK)
- PersonId (FK)
- Name
- Value
PROBLEM: I need to represent pet attributes, too. As it turns out, these pet attributes are, in most cases, identical to the attributes of a person (e.g. a pet can have an age, height, and weight too). How do I represent pet attributes?
- Do I create a PetAttribute table? - PetAttribute - Id (PK)
- PetId (FK)
- Name
- Value
 
- Do I change PersonAttribute to GenericAttribute and have 2 foreign keys in it - one connecting to Person, the other connecting to Pet? - GenericAttribute - Id (PK)
- PersonId (FK)
- PetId (FK)
- Name
- Value
 - NOTE: if PersonId is set, then PetId is not set. If PetId is set, PersonId is not set. 
- Do something else? 
© Stack Overflow or respective owner