I'd like to create a DB to store different rows type. It will be kind of event list with time stamp. So I'd like to have an Event
table with relations to other tables – each table will be a row type (Transition
, Position
, Error
):
Is this a good approach? Possible drawbacks:
- as a result I'll have to take care that every row in
Event
exactly 1 FKnot null
as it can relate to exactly 1 event - when adding new event type I'll have to upgrade*
Event
- when I'll have many event types the result will be that a row in
Event
table will have mostlynull
columns and only 1 will benot null
EDIT: Transition
, Position
, Error
, Location
tables has unique columns which are not put in the image above, e.g. Transition
has type
, Position
has 'latitude'/'longitude', Error
has payload
etc.
* By upgrade, I mean when I need to add new type to Event table I'll require rewrite whole Event table – as I'm working on Android it'll require using method SQLiteOpenHelper->onUpgrade.
Best Answer
You have it the other way round.
Put EventId and EventName on Event table and reference EventId in other tables. In other words,