1、数据库ER图练习及答案DB Modeling Exam PracticalAnswer the following questions.1.Create an E-R schema for a database system used to manage account information at a community bank. The bank has several branches with unique names. A customer may have one or more accounts in one or more branches. An account must
2、belong to one and only one branch. Each account is operated on by transactions, which may be deposits to or withdrawals from some account. The database keeps track of all the transactions on each account, in addition to the balance of individual accounts and the assets of individual branches. For ea
3、ch entity, specify all its attributes, primary key, and alternate key(s). In your ER schema, be sure to capture the cardinality constraints and participation constraints of all relationships. Make reasonable assumptions to complete the specification. Explicitly state all your assumptions. EVERY cons
4、truct in your ER schema should be substantiated by either the specification above or your explicit assumptions.2.The following table stores information about which suppliers can supply which parts. The table captures the fact that a part whose name is PartName and whose ID is PartID can be supplied
5、by suppliers whose names are in SupplierName and whose IDs are in SupplierID. Note that a part can be supplied by many suppliers, and a supplier can supply many parts. CAN_SUPPLYPartIDPartNameSupplierIDSupplierName1234Nut223ProMetal1234Nut224Biscayne2134Bolt223ProMetal3.Perform the following tasks.1
6、.List the primary key. 2.List all the FDs. 3.What normal form is the relation in Explain. 4.Apply normalization to it incrementally, carrying the normalization process through each of the higher normal forms possible up to 3NF. That is, if the relation were unnormalized, bring it to first normal for
7、m, then bring the first normal form youve just created to second normal form, and then bring the second normal form to third normal form. For each transformation to the next higher normal form X, Explain the steps you took to bring it to the normal form X. Provide the normal form Xs table structure,
8、 primary key(s), and the FDs. Explain why you think it is in the normal form X. For example, if you think there is a partial dependency, fully defend your conclusion by explaining how a column is partially dependent on some other column(s). That is, if the relation were in an unnormalized form, you
9、would explain the transformation you performed to bring it to first, second, and third normal forms. You would also provide the table structure, the primary key and the FDs for the first, second, and third normal forms. You would also provide explanation for why you believe it is in first, second, a
10、nd third normal forms. 4.Convert the following E-R schema into a relational schema using the mapping algorithm specified in this course. Specify key and referential integrity constraints, using directed arcs. Make sure you also identify alternate keys. Label each step of the mapping algorithm. Answe
11、r:1.Entity:1.Bank(BankName,BankPhone) (BankPhone is a multi-valued attribute.)PK: (BankName)2.Cutomer(CustID, CustName, PhoneNum)PK: (CustID)AK: (PhoneNum)3.Branch (BranchName, BranchAddr, BranchPhone, Assets) (BranchPhone is a multi-valued attribute.)PK: ( BranchName)4.Account (AccountNo, Balance)P
12、K: (AccountNo)5.Transaction (TID, OperationType, TDateTime)PK: (TID)Relations:1.Has: , 1:N, PARTIAL/ TOTAL;2.Open: , 1:N, PARTIAL/ TOTAL;3.AofBranch: , 1:N, PARTIAL/ TOTAL;4.TofAccount: , 1:N, PARTIAL/ TOTAL;Assumptions:1.A new bank can establish no branch.2.One normal bank establishes one or more b
13、raches.3.A bank has one or more telephones for customers.4.A customer can open one or more Account.5.An account must belong to one and only one branch. 6.One branch opens one or more accounts.7.A branch has one or more telephones for customers.8.An account belongs to just one branch;2.:(PartID, Supp
14、lierID):FD1: PartID-PartNameFD2: SupplierID-SupplierName3. The relation is in the first normal form(1NF). Each attribute of the relation allows a single atomic value, so it is in 1NF.But some none-primary-key attributes, such as PartName and SupplierName, partially dependant on the primary key (as F
15、D1 and FD2 show), so it is not in 2NF.4. Normalization:1) FD1: PartID-PartName The relation can be decomposited into two relations:PART(PartID, PartName),FDs=PartID-PartName, PK:(PartID);CAN_SUPLY(PartID, SupplierID, SuplierName), FDs=SupplierID-SupplierName), PK:(PartID,SupplierID). The relation PART is now in the third normal form because the only none-primary-key attribute PartName, fully (not partially) and directly (not transively) dependants on the primary key PartId. The relation CAN_SUPPLY is still in the first
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1