database - Is a bidirectional relationship appropriate for reference tables? -


please excuse me if stupid question, i'm new @ relational databases , can't seem find answer (probably because else knows answer).

i'm storing test data may include times in various formats different (tai, utc, gps, etc). i'm not sure want force times converted arbitrary consistent format before being input (or maybe that's best way?), assuming can keep flexibility, plan use reference table (lookup table) of time types so:

ref_time_types -------------- id (pk) desc (utc, gps, tai, etc) 

and i'll have table store actual times:

tbl_time ------------- id (pk) ref_time_types.id (fk) seconds year . . . 

my question i'm sure basic. should establish bidirectional relationship between these, or unidirectional many-to-one tbl_time ref_time_types? can't think of reason want find utc times, example. guiding principle on whether create bidirectional relationship? there best practice when comes relationships reference tables?

i'm using python, sqlalchemy, , sqlite if makes difference.

do need preserve format?

  1. if no, don't store in database. database storing data, shouldn't care how data represented in ui. so, i'd recommend handle input want in ui (if means multiple formats, it), convert consistent format before storing database , rid of ref_time_types altogether.
  2. if yes, go ahead , store format well, i'd still use consistent representation of date/time since require less conversions when querying (you need convert input criteria query, instead of rows don't match desired format).

also, use date/time type supported dbms - don't see particular reason split various date/time components separate fields unless want query on these individual components (and want index them).

should establish bidirectional relationship between these, or unidirectional many-to-one tbl_time ref_time_types?

as discussed above, won't need relationship in first case (since there 1 table). relationship many-to-1 second case.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -