I am creating a database for a DVD rental shop, I have various entities that are related to this question, such as Film, FilmStar.
For each film, you record its unique number, title, the year in which it was made, its category (action adventure, science fiction, horror, romance, comedy, classic, children's), its director, and all stars that appeared in it. For each film, you also want to store the type of DVD hire (new release, classics, other).
I am mostly unsure about "all the stars that appeared in it". I first thought just having an attribute in the 'Film' Entity, for example filmStar and then each star would be inserted into that attribute, for example: "John Doe, Jane Doe" for each film. But then I realised that this wouldn't be 1NF as : "the domains of attributes must include only atomic values, the value of an attribute must be a single value from the domain of that attribute", as it contains more than one value and isn't atomic.
I then thought about having a separate entity that contains certain attributes such as: filmID, filmStarID. So John Doe would have the filmStarID of '0001' (all of this would be in the FilmStar entity, which is a separate entity). But then the same problem would occur, for example the filmID attribute would have all of the filmID's that the filmStar has starred in, for example: John Doe would have "101, 115, 009". Which again wouldn't be 1NF.
I was just wondering what your thoughts are on this?
Best Answer
You're on the right track with splitting up your domains and using a linking entity. Separating the
Film
s from theStar
s is absolutely the first step.The missing piece is tying the two together. Obviously, stuffing the
StarID
s into theFilm
table is in violation of the first normal form, since you end up needing to store multiple references to actors in a single row.Splitting the offending column out to its own table restores the integrity of the original
Film
table, but continuing to store multiple references in a single attribute still invalidates 1NF for the data model.To rectify this is fairly simple, as you merely need to associate each
FilmID
with the respectiveStarID
, bringing your model in-line with the tenants of 1NF.Now, with the the data normalized in this manner, it is easy to add attributes to expand the model. Say an actor's character name in a movie was desirable, you could add
CharacterName
to theFilmStar
table - maybe useful for getting a list of everybody who's ever played "James Bond," for instance.