mysql - How to manage entity duplication in database table -
i working on simple database design of application. have book illustrator , editor table.
with model, think here duplication of column name in each author
editor
, illustrator
table.
what if book author, illustrator , editor person same, in case, data duplicated across 3 tables.
but in case of searching faster, guess no of items per table less.
modelling 2
modeling, author, illustrator , editor info saved in single table , confused should name of table.
with approach. data won't' duplicated searching double compared model 1.
can suggest me model should choose. feel modeling 2 better.
it purely taste model should use. second 1 has advantage wont duplicates. both models can results 1 query
select * books left join names auth on (auth.id = author_id) left join names ill on (ill.id = illustrator_id) left join names ed on (ed.id = editor_id) books.id = 1;
sqlfiddle gives example of model 2. if want obtain data model one, change 3 joins right table.
if want display list of authors, not recommend adding new field in names table, use joint query.
select auth.* books left join names auth on (auth.id = author_id)
as long set indexes on id
, author_id
, illustrator_id
, editor_id
, fine.
edit: preference go model 2. think might bit faster:
- the database needs open 1 file (not 3)
- there less records in table (compared combined of 3 tables) because don't have duplicates.
- the database need search through 1 index set (not 3) , might optimised stuff in because looking 3 keys in same set (instead of 3 key in 3 index sets) - it's gut feeling, not sure if correct...
Comments
Post a Comment