ER Diagram that implements Actors Database [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 09:28:39

问题


Note: This is a rough copy i didnt include constraints, weak entities, ..., etc yet. I still need to have a solid understanding of this question.

Questions:

  1. To keep track of what theater company manages performer, what performer is in two theatre companies do i have to make a unique code for each entity set in other entity sets to keep track of them?

  2. Can start_Location simply point to Place for the theatre company entity?

  3. Can an Actor be Born in a place or does it have to have a attribute that points to place?

  4. Do my relationships so far make sense?

  5. Are there any redundant attributes such as Short_Descript in Plays?

  6. Can i make an attribute in Place called "Town, State/Department/Province"? Or does it have to be a composed attribute?

Please note: I will be editing and updating my diagram if I have more questions and such...

I would appreciate any suggestions or hints.

ERD:

Question Information:

An actor is born in a place and he/she lives presently in a place (this information is mandatory).

We store in the database only the last known place where the actor lives.

We need the following information for an actor: actor number, actor name , date when actor was born, and date when actor died (check if died > born).

An actor is a performer, or/and a theater director. We store for performer the date when he/she started to perform.

We store for theater director the date when starts his/her last employment as theater director

We consider in DBActors the following types of plays: drama, comedy and tragedy.

For each we like to store the following data: play’s number , play’s title , play’s short description , year when it was written ,date when it was first presented on stage(p_date_p, date).

For dramas we store also the drama type,name of the main positive character, and name of main negative character.

The drama type is one of the following: “classical”, “medieval”, “renaissance”, “nineteenth-century”, “modern”, and “contemporary”

For comedies we store the comedy type, the name of main character , and the name of the second character

The comedy type is one of the following: “ancient mroman”, “ancient greek”, “farce”, “comedy of humors”, “comedy of manners”, “commedia dell’arte”, and “theater of absurd”;

For tragedies we store the tragedy type(t_type, varchar(20)),and name of main character

The tragedy type is one of the following: “Greek”, “Roman”, “Renaissance”, “Neo -classical”, and “Modern”

A play is written by one or many dramatists It is possible that we do not know the dramatist for certain plays.

We store in the database all known plays even if they were not performed (“closet plays”)

Some actors are also dramatists.

We store in the database all known mdramatists.

An actor is hired by a unique theater company at any timestamp

He/she will stay in the same company the whole year when he/she was hired.

We store in the database the year when he/she was hired by the theater company (small integer)

It is possible that the actor changes the theater company where he/she is working during his/her life many times. It is possible that an actor is hired by the same company many times in different years. He/she can perform in one or many plays (at least one)

which are presented by theater companies.

It is possible that an actor is hired by a theater company and performs in a play presented by another theater company.

It is unusual but possible that the same performer plays in the same play presented by different theater companies. A theater company performs/presents one or many plays every year.

Same play can be performed by one or many distinct theater companies.

We like to store in the database the date when the play starts to be performed by a theater company.

It is possible that the same play is performed by different theater companies starting at same date.

We need to store for a dramatist his/her dramatist number,his/her name.

A dramatist wrote one or many plays(at least one).

The information to be stored in the database for each theater company is: theater company number,theater company name , date when the theater company started.

For each theater company we store in the database the first location (place) where the theater company started

There might be more than one theater company starting in the same place.

A theater company must hire at least one actor.

Each theater company has a unique theater director. He/she starts his/her work at a specific date.

It is possible that the same theater company has different theater directors but at distinct times and the same theater director manages different theater companies in distinct times(never at the same date).

It is possible that the same theater director manages the same theater company at different dates.

The information to be stored for place is: place number, town and state/department/province, place country


回答1:


Here are my responses to your questions:

  1. Whenever you look at two tables and see a Many to Many relationship, you can solve the problem easily using a linker table. Also known as a junction table “is a database table that contains common fields from two or more other database tables within the same database. It is on the many side of a one-to-many relationship with each of the other tables. Junction tables are known under many names, among them cross-reference table, bridge table, join table, map table, intersection table, linking table, many-to-many resolver, link table, pairing table, transition table, crosswalk, associative entity or association table.” Wikipedia example You saw me use these tables in your previous question. In this case you are stating that an actor can be managed my many Theater Companies and A Theater Company and also manage many Actors. This is a many to many so if you created a link table in between those tables for every relastionship between the two you’d add a new row in the link table that only contains a theater Company id and an actor id. If an actor was managed by many theater companies then you’d add several rows to the link table each holding the same actor id but each row having a different theater company’s id.
  2. Yes, you can have start_Location point directly to place. This means that that Start_Location attribute must be a Foreign Key (FK) pointing the theater company to the Primary Key (PK) of the related Place record.
  3. By all means an actor can be born in a place, but just like above, you need a column in Actor, that is a FK to the Place Table’s PK. You could call this column Birth_Place and all it’d hold is the PK of the record in Place that relates to the actor’s birth place. This column would also need to be NOT NULL because all actor’s need a Birth_Place.
  4. So far it seems like your diagram will work to solve this problem, yes. Just see question 1’s answer for that follow up addition.
  5. You’re getting good at removing redundancies. Your diagram looks good. The only suggestion, I’d make is why do you have a play table and then 3 separate play type tables? Why not add them together in on Table called Play. It’d sit exactly where Play currently sits in your diagram and contain the same attributes it already does, but you also add the following:

    a. Type – Would be a string that you could place “Drama”, “Comedy”, or “Tradegy” in so you’d know exactly what type of play it is. Also this would allow you to add future play types to the plays table and not have to add a whole new table to the DB.

    b. Sub_Type – Would also be a string and hold the type that you currently have under the separate tables. They are all essentially the same attribute in each table and would just hold different type descriptors depending on the parent Type.

    c. Main_Character – Would be a string that holds the main character, because in your three separate tables, you have main characters. You’re just calling them 3 separate things. (get the direction I’m going in here? )

    d. Secondary_Character – Would be a string that holds the secondary character. You have a secondary character in your dramas and comedies, but non in your tradegies so in tradegy records this column would wind up being null. See what I did there? You now have one table where you used to have 4, and in that one table you can retrieve all the same information you had in those 4 separate tables. Hopefully that’ll make your life easier.

  6. You can do whatever you like, but I’m assuming you mean by best practices and it would be generally considered best practice to separate this single attribute into it’s Simple attribute sub parts. I.E. make it a composed attribute.


来源:https://stackoverflow.com/questions/28096460/er-diagram-that-implements-actors-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!