3 ms·
As other people are saying, you haven't really given enough information for someone to suggest a definitive data model. By "Pet" class, do you mean a table for
by bpyne 7y ago
As other people are saying, you haven't really given enough information for someone to suggest a definitive data model.
By "Pet" class, do you mean a table for pet records?
Pets are animals that humans decide to take care of. Should a "Pet" be a state of an Animal? So, should it be a simple boolean column on the Animal table?
Having an AnimalRabbit table implies a many-to-many relationship between Animal and Rabbit. Are you storing different rabbit types as parent records? If so, why not avoid the join table, store "rabbit" as a record in the Animal table, and have the different rabbit types in the Rabbit table.
Without more detail on what you're trying to do from an application standpoint, it's tough to give recommendations. Entity-Relationship Modeling purists believe in defining entities and their relationships without implementation detail. I've always found that to be a crock. You need a certain amount of detail to model better.
- m33k44 7y ago> By "Pet" class, do you mean a table for pet records? Yes. > Having an AnimalRabbit table implies a many-to-many relationship between Animal and Rabbit. Are you storing different rabbit types as parent records? The whole point on making an Animal table was so that it could be referenced by the Pet table, because Pets can be more than one type. If I include Dog and Cat directly in Pet table then there will be lots of fields in the Pet table empty; also tomorrow if I want to add Rabbit as a Pet then I need to modify the Pet table to include Rabbit fields with null values in the previous rows. Having a separate Animal table allows me to add new types of Pets without modifying the Pet table and also saves table space.
- bpyne 7y agoTo reiterate, without knowing about your application, it isn't easy to make recommendations. It sounds like the Animal table is going to be the join table between Pet and the different types of animal tables. Correct? You haven't mentioned a need to store differentiating information - e.g. species, genus, family - in the different animal tables (Dog, Cat, etc.). So it sounds like you could skip the one table per animal notion and just have the Animal table contain animal types like rabbit, dog, etc. Then it becomes the "one" in the one-to-many relationship with Pet.
- m33k44 7y ago> It sounds like the Animal table is going to be the join table between Pet and the different types of animal tables. Correct? Yes, that is correct.