I have a <person> table, a <house> table and need to register people's tenancy in these houses.
First thought is to create a <tenancy> table with foreign keys to <person> and <house> tables. So far so good.
A tenancy will have a start date and an end date, no problem there. However, a business rule says that a person cannot be a tenant in more than on house at a time so an interdependence happens between records in the <tenancy> table. In this design I must check in the <tenancy> that the business rule isn't broken before a new record can be accepted. This doesn't sound good to me.
What does database theory have to say about that? How do I design this?
Please excuse any lack of proper database terminology.
Thanks.
First thought is to create a <tenancy> table with foreign keys to <person> and <house> tables. So far so good.
A tenancy will have a start date and an end date, no problem there. However, a business rule says that a person cannot be a tenant in more than on house at a time so an interdependence happens between records in the <tenancy> table. In this design I must check in the <tenancy> that the business rule isn't broken before a new record can be accepted. This doesn't sound good to me.
What does database theory have to say about that? How do I design this?
Please excuse any lack of proper database terminology.
Thanks.