views:

30

answers:

1

I need to model the following relationships and would like some advice on how to properly model it.

There is a user, house, apartment, garden, furniture

  1. So a user can either have a house or an apartment but not both.

  2. Both house and apartment can have furniture but only the house can have garden.

So the biggest issue is user has_one house | has_one apartment, how can I model this ?

+2  A: 

Consider using single table inheritance for this (a little wasteful because of all the null gardens, but depending on the scale of your db, that may not end up being an issue), or possibly a polymorphic relationship (user has_one dwelling).

Ben Taitelbaum