Quote:
|
Originally Posted by Eric the Red
However, someone has told me that I have poor database design because inside my movie table "CompleteCast" I'm using delimited fields for my actors.
I've already got separate tables for both "actor" and "movies" so why is this a bad thing and what can I do to change this problem?
|
There's nothing fundamentally wrong with storing delimited strings in a column but in this case it's unlikely to be very practical.
For example: How will you ensure that the actor names in the cast column correspond to those in your Actor table? It's very difficult to enforce such a rule in the database. How will you locate and update every reference to an actor's name if it appears in lots of delimited strings (for example if an actor's name changes or needs correcting)? Finally, and most obviously, how do you expect to answer such queries as "Show me all the films in which Marlon Brando appeared"? It's very hard to do that efficiently if you first have to parse a string on every single row.
The solution is to create a new table that joins actors to movies, probably with just two attributes (like: ActorMovie {Actor, Movie} where {Actor, Movie} is also the key of the table). This is often called a "joining table" or "association table" although personally I don't find that terminology very useful.