四、综合题(本大题共8小题,每小题5分,共40分)

Section One:Testing your basic knowledge. Please fill in the blank with proper
words(30 points, 1 points per blank)
1) A table that displays data redundancies yields probably Update, Insertion and Deletion
anomalies.
2) A table where all attributes are dependent on the primary key and are independent of each
other, and no row contains two or more multivalued facts about an entity, is said to be
in__4__normal form.
3) A Relational operator that combines all rows from two tables is considered to be a
Product / union.
4) The Evolution of Data Processing experiences three stages: 1) Manual filing system; 2)
File-based system; 3) Database system.
5) A database designer uses a DDL to define a schema for the database. The schema is
maintained and stored in the system catalog /data dictionary /data directory.
6) Logically related data comprises entities, attributes, and relationships of an organization’s
information.
7) DBMSs Provide efficient; convenient, and safe accesses to massive amounts of
persistent data.
8) Advantages of DBMSs include : 1) data independence / Data access transparency;
2) Sharing of data;
3) Data consistency/integrity; 4) concurrency, backup and
recovery ; 5)Security.
9) Eight services that a DBMS should provide (Codd 82):
1) Data storage, retrieval, and
update; 2) A user-accessible catalog describing data items;
3) Transaction support; 4)
Concurrency control services;
6) Authorization /security
services;
5) Recovery services;
7) Support for data communication (network access); 8) Data integrity
services.
10) Data Model comprises: 1) a structural part; 2) a manipulative part; 3) possibly a set of
integrity rules / constraints.
11) The cardinality of a relation is the number of tuples it contains.
第 1 页( 共 8 页)
12) Minimum elements granularity for select privilege in DDL is table / relation
13) Four basic (ACID) properties of a transaction are: Atomicity, Consistency, Isolation,
Durability.
15) Query Processing transform query written in high-level language/ declarative
language/ non-procedural
(e.g. SQL), into correct and efficient execution strategy
expressed in low-level language / execution /procedure (e.g. RA);
16) Physical Database Design involves : 1) Translate global logical data model / relation
for target DBMS; 2) Design physical representation 3) Design user views; 4) Design
security mechanisms; 5) Consider the introduction of controlled redundancy; 6) Monitor
and tune the operational system
Section Two: Multiple-choice test, there are at least one correct option for each
question. If your choice is less or more than all correct options, no point for you.(20
points, 2 points per each)
1). The relationship among DB, DBS and DBMS is ( B
)
A. DB doesn’t include DB and DBS;
B. DBS includes DB and DBMS;
C. DBMS includes DB and DBS.
2). Which data model can use “pointer” to implement the relationship of entities? ( B, C )
A. relational model;
B. network model;
C. hierarchical model.
3). Physical database design is ( B)
A. irrelevant to requirements analysis;
B. relevant to operation system;
C. irrelevant to DBMS.
4). If each candidate key of 1NF relation only contains one attribute, then this relation must
be ( A )
A. 2NF;
B. 3NF;
C. BCNF.
5). If there is not common attribute, the natural join may be ( A )
A. Cartesian Product;
B. equijion;
C. union operation.
6). In relational DB system, a view can derive from ( B, C )
第 2 页( 共 8 页)
A. only one base table;
B. the other view;
C. more than one base relation
7). In hierarchical model, besides the root node, ( C )
A. no other node exists ancestor;
B. node have one child at most;
C. node have one parent at most.
8). In RDBMS, user can improve access efficiency through ( A, B, C )
A. creating index;
B. creating cluster;
C. reasonable redundancy.
9). There is/are ( B ) candidate key(s) in any relation schema.
A. at most one;
B. at least one;
C. more than one.
10). ( A, B, C ) can be appear in WHERE clause expression in SELECT statement.
A. relation name;
B. attribute name;
C.constant.
Section Three: Testing ability of application of knowledge(10 points)
The table shows below lists dentist/patient appointment data. A patient is given an appointment at a
specific time and date with a dentist located at a particular surgery. On each day of patient appointments, a
dentist is allocated to a specific surgery for that day.
Describe and illustrate the process of normalizing the table shown above to 3NF. State any assumptions
you make about the data shown in this table.
The result of normalization should be a set of relations that is in 3NF, such as Patient(C1, C2, C3), or a set
of dependency diagrams where the key attributes are underlined and which is in 3NF.
Are the relations in BCNF?
All Functional dependencies are shown as follows
Fd1
StaffNo
Fd2
dentistName
PatNo
PatName
Appointment
date
Appointment
Time
SurgeryNo
Fd3
Fd4
第 3 页( 共 8 页)
Fd5
Fd6
Fd7
Fd8
Fd9
So the relation can be decomposed into four relations as follows:
1) Staff(StaffNo, dentistName)
2) Patient(PatNo, PatName);
3) Arrange(StaffNo, Appointment_date, SurgeryNo)
Its another candidate key: Appointment_date, SurgeryNo.
4) Appointment(StaffNo, PatNo, Appointment_date, Appointment_Time)
Its other candidate keys: 1) StaffNo, Appointment_date, Appointment_Time.
2) PatNo, Appointment_date, Appointment_Time
The four relations are in BCNF.
Section four: Comprehensive Capability Test(40 points)
Please design a database for track meet (田径运动会) of hunan university. Every college(学院)
designates a delegation(派一个代表团) to take part in track meet. A delegation consists of a
leader, some athletes(运动员), some refrees(裁判). Each athlete can participate in one or more
sport items.
User output reports include:
1) the list of sport items (code of sport item, name of sport item,spot (竞赛地点), time(竞赛时间),
referee) .
2) The list of participations (name of sport item, code of sportsman, name of sportman, birthdate)
3) the list of racing results (name of sport item, code of sportsman, name of sportman, result(成
绩), rank (名次), score(得分)).
4) The list of all members in track meet (name of college, name, sex, birthdate).
5) The list of all delegations (college code, college name, leader, the number of gold medal, the
number of silver medal, the number of medal, total scores).
Please you design a database. Requirements include:
1) Your database can meet the user business demands.
2) Cascade update. No action on delete if dependency exist;
3) Referee can not take part in any sport item. delegation leader can neither sportsman nor
referee.
第 4 页( 共 8 页)
4) It is possible that a college has not a sportsman.
5) No more than three tables in your database.
6) There is redundancy as little as possible.
7) No update, delete, insert abnormality.
1) Draw the ER diagram using UML specification. (9 points)
Delegation
Person
dcode{PK}
dname
pcode{PK}
pname
sex
birthdate
1..1
0..1
Has
Lead
0..*
1..1
result
rank
score
SportItem
0..* Participate
0..*
1..1
0..1
Referee
scode{PK}
sname
spot
time
2) Write DDL sentences for the creation of the tables you define in design. (9 points)
CREATE TABLE Delegation (
dcode char(4) NOT NULL,
dname varchar(12) NOT NULL,
leaderno char(4),
PRIMARY KEY(dcode),
FOREIGN KEY(leaderno) REFERENCE Person ON DELETE NO ACTION ON
UPDATE CASCADE);
CREATE TABLE Person (
pcode char(4) NOT NULL,
pname varchar(8) NOT NULL,
sex char(1),
birthdate date,
dno char(4)
PRIMARY KEY(pcode),
FOREIGN KEY(dno) REFERENCE Delegation ON DELETE NO ACTION ON
UPDATE CASCADE);
CREATE TABLE SportItem (
scode char(4) NOT NULL,
sname varchar(8) NOT NULL,
spot varchar(20),
start_time timestamp,
refereeno char(4),
PRIMARY KEY(scode),
FOREIGN KEY(refereeno) REFERENCE Person ON DELETE NO ACTION ON
UPDATE CASCADE);
第 5 页( 共 8 页)
CREATE TABLE participation (
scode char(4) NOT NULL,
pcode char(4) NOT NULL,
result decimal(5.2),
rank smallint,
score smallint
PRIMARY KEY(scode,pcode),
FOREIGN KEY(scode) REFERENCE SportItem ON DELETE NO ACTION ON
UPDATE CASCADE)
FOREIGN KEY(pcode) REFERENCE Person ON DELETE NO ACTION ON
UPDATE CASCADE);
CREATE ASSERTION sport_rule1
CHECK( NOT EXISTS (SELECT pcode FROM participation as P,
delegation as D WHERE P.pcode = D.leaderno));
CREATE ASSERTION sport_rule2
CHECK( NOT EXISTS (SELECT pcode FROM, SportItem as S,
participation as P WHERE S.refereeno = P.pcode);
3) Write DML sentences for following questions. (For each questions, one or several SQL
sentences are allowed).
a) Delete the racing record of those persons that have not got any medal. (3 points)
DELETE FROM participation where rank > 3;
b) Output all sportsman (name, sex, birthdate) whose name contain only two Chinese
characters. (3 points)
SELECT P.pname, P.sex, P.birthdate FROM person AS P, Participation AS A
WHERE A.pcode = P.pcode and P.pname like ‘_ _ _ _’;
c) Output those persons (college name, person name) who is either leader or referee. (4
points)
SELECT dname, pname FROM person AS P, delegation AS D WHERE P.dno =
D.dcode AND P.pcode NOT IN (SELECT DISTINCT pcode FROM participation);
d) Output those colleges, each of which doesn’t take part in any sport item. (4 points)
SELECT DISTINCT dname FROM delegation AS D, person AS P WHERE P.dno
= D.dcode AND NOT EXISTS (SELECT pcode FROM participation AS A WHERE
A.pcode = P.pcode);
e) Output list of all colleges (college code, college name, the number of total medals) in
descending order. (4 points)
SELECT dcode, dname, count(*) AS medals FROM delegation AS D, person
AS P, participation AS A WHERE P.dno = D.dcode AND P.pcode = A.pcode
AND A.rank < 4 GROUP BY dcode ORDER BY medals DESC;
4) Output the list of all delegations (college code, college name, leader, the number of gold
medal, the number of silver medal, the number of medal, total scores). (you may write several
DML sentences) (4 points)
SELECT dcode, dname, pname, count(*) AS gold INTO tmptbl1 FROM
第 6 页( 共 8 页)
delegation AS D, person AS P, participation AS A WHERE P.dno = D.dcode
AND P.pcode = A.pcode AND A.rank = 1 GROUP BY dcode;
SELECT dcode, dname, pname, 0 AS gold INTO tmptbl10 FROM delegation AS
D, person AS P WHERE D.dcode = P.dno and NOT EXISTS( SELECT pcode
FROM participation AS A WHERE A.pcode = P.pcode AND A.rank = 1 );
SELECT dno, count(*) AS silver INTO tmptbl2 FROM person AS P, participation
AS A WHERE P.pcode = A.pcode AND A.rank = 2 GROUP BY dno;
SELECT dno, 0 AS AS silver INTO tmptbl20 FROM person AS P where NOT
EXISTS( SELECT pcode FROM participation AS A WHERE A.pcode = P.pcode
AND A.rank=2 );
SELECT dno, count(*) AS copper INTO tmptbl3 FROM person AS P,
participation AS A WHERE P.pcode = A.pcode AND A.rank = 3 GROUP BY dno;
SELECT dno, 0 AS copper INTO tmptbl30 FROM person AS P WHERE NOT
EXISTS( SELECT pcode FROM participation AS A WHERE A.pcode = P.pcode
AND A.rank=3 );
SELECT dno, sum(score) AS score INTO tmptbl4 FROM person AS P,
participation AS A WHERE P.pcode = A.pcode AND GROUP BY dno;
SELECT dno, 0 AS score AS score INTO tmptbl40 FROM person AS P, WHERE
NOT EXISTS( SELECT pcode FROM participation AS A WHERE A.pcode =
P.pcode );
SELECT tbl1.dcode, tbl1.dname, tbl1.pname, gold, silver, copper,
gold+silver+copper, score FROM tmptbl1 UNION tmptbl10 AS tbl1, tmptbl2
UNION tmptbl20 AS tbl2, tmptbl3 UNION tmptbl30 AS tbl3, tmptbl4 UNION
tmptbl40 AS tbl4 WHERE tbl1. dcode = tbl2. dno AND tbl1. dcode = tbl3. dno
AND tbl1. dcode = tbl4. dno
第 7 页( 共 8 页)