3

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):
enter image description here
Is this a good approach? Possible drawbacks:

  • as a result I'll have to take care that every row in Event exactly 1 FK not 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 mostly null columns and only 1 will be not 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.

0
1

You have it the other way round.

Put EventId and EventName on Event table and reference EventId in other tables. In other words,

  1. Add EventId column in Transition, Position and Error tables.
  2. Remove time_stamp, transition_id, position_id, and error_id from the Event table.
2
  • But then all unique columns from tables Transition, Position and Error should be in Event table. This is not what I want. Jan 19 '15 at 8:11
  • Why would all unique columns from tables Transition, Position and Error should be in Event table?
    – GMalla
    Jan 21 '15 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.