I need to create a database for 2 types of farmers (organizations and landlords) which have different columns that need to be stored and I also need to version their info.
One db design that I came up with is this: (the consistent one)
Farmers
Id
FType check(FType in ('organization', 'landlord'))
Unique(Id,Ftype)
Organizations
Id
FType
Unique(Id, FType)
FK(Id, FType) Ref Farmers(Id, FType)
LandLords
Id
FType
Unique(Id, FType)
FK(Id, FType) Ref Farmers(Id, FType)
OrganisationVersions
Id
OrganisationId ref Organizations(id)
--lots of stuff specific to organisation
Startdate
Endate -- if null than this is the current version
LandLordVersions
Id
LandLordId ref LandLords(id)
--lots of stuff specific to landlord
StartDate
EndDate
The second one not so consistent but much less tables is like this:
Farmers
Id
FType
Organizations
Id
FarmerId ref Farmers(Id)
--stuff
StartDate
EndDate -- if null than this is the current version
LandLords
Id
FarmerId ref Farmers(Id)
--stuff
StartDate
EndDate