简体   繁体   中英

My database design for movie database

If it best way to Normalize???

1:Actors:-
Id
Name
Sex
DOB
BIO

2:Movies:-
Id
Name
Year of release
Plot
Poster
Foreign Key(ProducerId)

3:Producers:-
Id
Name
Sex
DOB
Bio

4:-MovieActorsMap
Primary Key(Foreign Key(ActorId)
Foreign Key(MovieId))

RelationShips:-

  • Actor can act in multiple movies
  • Movie can have multiple actors
  • Movie has only one producer
  • Producer can produce multiple movies

I am right to create databse table???

Producers and Actors have identical fields so you could move them in one table Persons and add a forign key id_type to differentiate between various types of people that can be in a movie. Of course youll need to add one more table Type with two fields id and title

you can create actors and ditectors in the entitytype table. eg. type1 director type2 actor that way it will be easy to add more members(entity) in future

   1:Persons:-
    Id
    EntityTypeId
    Name
    Gender
    DOB
    BIO

    2:Movies:-
    Id
    Name
    Year of release
    Plot
    Poster
    Foreign Key(ProducerId)

    3:EntityType:-
    EntityTypeId
    Entity

    4:-MovieActorsMap
    Primary Key(Foreign Key(ActorId)
    Foreign Key(MovieId))

Change this:

4:-MovieActorsMap Primary Key(Id) auto increment Foreign Key(ActorId) Foreign Key(MovieId)

An actor can make several movies, if you put him as a primary key, he can only make one movie.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM