[mythtv] Database normalization things

Ben Bucksch linux.news at bucksch.org
Wed Jul 9 22:41:58 EDT 2003


mike wrote:

>1. Primary keys on all tables are autoincrement-ints.
>
Not a good idea, IMHO. Primary keys as int on (almost) all tables might 
make sense, but autoincrements have severe problems for important tables 
like channel. If you blow away your channel table (e.g. to regenerate 
it), you must have a way to reassign the exact same IDs to the same 
channels as in the old content, otherwise all the foreign keys in the 
other tables and the filenames of the recordings will all be wrong. Same 
probably applies to other tables as well. Primary keys already assure 
uniqueness.

>2. Change cases of primary keys convering multiple columns to unique
>keys.  Again, this would help future joins.
>
I agree here. The lack of a single primary key for e.g. the recorded 
table was quite a pain when I wrote the alternate EPG. I guess that 
could simplify the code somewhat. We could probably also save a lot of 
space by having only a single int column in credits refer to the program 
instead of an int and a 10(14?)-byte date field.

>3. Add keys to fields that are frequently looked at.
>
I think you mean indexes?



More information about the mythtv-dev mailing list