E-R图

  • Question1、There are many teachers in a certain department and each teacher belongs to only one department. A department has any number of scientific research projects and each project is managed exactly by one department. For each project, more than 2 but less than 20 teachers participate in and each teacher can participate in more than one project or no project. Teachers participate in the project to count the workload. Department are with the following attributes: number, name, address,tel number. Teachers have the attributes as follows: number, name, sex, age, title of an teacher. Research projects are with the following attributes: project number, project name, cost,location. Please complete the following design:
    (1)Design ER diagram and indicate entities , attributes, relationship between them and participation constrains of it.
    (2)Design relational schema based on ER diagram, for each relation, define the relation name, attribute names,datatype, primary key, and foreign key( if any).
    (3) Explain two of relations you design belongs to 3NF according to some hypothesis you make in the real world.
  • answer1
    (1) ER diagram
    E-R图
    (2)Relations:
    Department(dnum,dname,address,tel),pramary key:dnum;
    Teacher(tnum,tname,sex,age,title,dnum), primary key:tnum;forign key:dnum
    project(pnum,pname,cost,loc,dnum),primary key:pnum; forign key:dnum
    join(tnum,pnum,workload), primary key:(tnum,pnum); forign key:dnum, tnum
    (3)
    primary key: (tnum,pnum);(tnum,pnum)workload
    no nonprime attribute workload is partly functinal depenced on (tnum,pnum) and transitived dependenced on (tnum,pnum);so it is in 3NF.
    Teacher:
    primary key: tnum; if two teacher may have same names.
    no nonprime attribute is partly functinal depenced on tnum and not transitived dependenced on tnum;so it is in 3NF.
  • Question2、A Bank’s database includes BANK, BANK_BRANCH, ACCOUNT, LOAN and CUSTMER entities, and the ER model is shown as the following diagram. According to the EER model and actual requirements:
    (1)List the strong (nonweak) entity types in the ER diagram.
    (2)List the weak entity and give the partial key and primary key of it.
    (3)What is the meaning of the constraints M and double line of the relationship L_C in the loan entity side?
    (4) How do you handle ACCTS and LOANS relationships when mapping to relational schema?
    (5)How do you handle A_C relationship when they are mapped to relational schemas?
  • answer2:
    (1)Strong entity : BANK, ACCOUNT, LOAN and CUSTMER;
    (2) Weak entity: BANK_BRANCH; partial key:Branch_no; primary key:( Branch_no,Bank_code);
    (3)M: One customer has at most M loans; double line: Each loan must belong to at least one customer.
    (4)ACCTS: combine it into ACCOUNT by adding (bank_code, Branch_no) to Account; combine it into LOAN by adding (bank_code, Branch_no) to LOAN.
    (5) A_C(Acct_no,Ssn,OpenDateTime)
  • Question3、A car dealer database includes VEHICLE, CAR, TRUCK, SUV, CUSTMER and SALESPERSON entities, and the EER model is shown as the following diagram. According to the EER model and actual requirements:
    (1)List the Superclass entity type(s) in the ER diagram.
    (2)List the Subclass entity type(s).
    (3)What is the meaning of the constraints d and double line connected to VEHICLE entity?
    (4) How do you handle VEHICLE, CAR, TRUCK, SUV when mapping to relational schema?
    (5)What type is the relationship SALE?Please list the attributes when mapping it to relation and give suitable explaination.
  • answer3:
    (1) Superclass entity : VEHICLE;
    (2) Subclass entity type: CAR\TRUCK\SUV;
    (3)d: One vehicle belong to exactly one subclass of car, truck and sub; double line: Every vehicle must belong to one customer.
    (4)
    Vehicle(Vin,Price,Model)
    Car(Vin,Engine_size, Price,Model)
    Truck(Vin,Tonnage, Price,Model)
    Suv(Vin,No_seats, Price,Model)
    (5) ternary relationship, when mapping it to relation, sale(vin,sid,Ssn,Date), the primary key is vin,sid,Ssn,which respectively from three entities amongthe relationship sale, and add the date attribute of itsself to the relation.

相关文章: