问题 问答题

设职工—社团数据库有3个基本表:
职工(职工号,姓名,年龄,性别)。
社会团体(编号,名称,负责人,活动地点)。
参加(职工号,编号,参加日期)。
其中:
(1)职工表的主码为职工号。
(2)社会团体表的主码为编号,外码为负责人,被参照表为职工表,对应属性为职工号。
(3)参加表的职工号和编号为主码;职工号为外码,其被参照表为职工表,对应属性为职工号;编号为外码,其被参照表为
社会团体表,对应属性为编号。
试用SQL语句表达下列操作:
(1)定义职工表、社会团体表和参加表,并说明其主码和参照关系。
(2)建立下列两个视图。
社团负责人(编号,名称,负责人职工号,负责人姓名,负责人性别)。
参加人情况(职工号,姓名,社团编号,社团名称,参加日期)
(3)查找没有参加任何团体的职工情况。
(4)查找参加了职工号为“1001”的职工所参加的全部社会团体的职工号。
(5)把对社会团体和参加两个表的数据查看、插入和删除数据的权力赋给用户张三,并允许他将此权力授予其他用户。

答案

参考答案:CREATE TABLE职工(职工号 CHAR(8) NOT NULL UNIQUE,姓名 CHAR(8)NOT NULL,年龄SMALLINT,性别 CHAR(2),CONSTRAINT Cl CHECK(性别IN(’男’,’女’)));
CREATE TABLE社会团体(编号 CHAR(8)NOT NULL UNIQUE,名称 CHAR(12)NOT NULL,负责人 CHAR(8),活动地点 VARCHAR(50),CONSTRAINT C2 FOREIGN KEY(负责人)REFERENCES职工 (职工号));
CREATE TABLE参加(职工号CHAR(8),编号CHAR(8),参加日期 DATA,CONSTRAINT C3 PRIMARY KEY(职工号,编号),CONSTRAIN C3 FOREIGN KEY(职工号)REFERENCES职工(职工号));
(2)CREATE VIEW社团负责人(编号,名称,负责人职工号,负责人姓名,负责人性别) AS SELECT编号,名称,负责人,姓名,性别FROM社会团体,职工WHERE社会团体.负责人=职工.职工号;
CREATE VIEW参加人情况(职工号,姓名,社团编号,参加日期)AS SELECT参加.职员号,姓名,社会团体.编号,名称,参加日期FROM职工,社会团体,参加WHERE职工,职工号=参加.职工号AND参加.编号=社会团体.编号;
(3)SELECT*FROM职工WHERE NOT EXISTS( SELECT*FORM参加WHERE参加.职工号=职工.职工号);
(4)SELECT职工号 FROM 职工 WHERE NOT EXISTS(SELECT* FROM参加 参加1 WHERE 参加1.职工号=’1001’AND NOT EXISTS (SELECT*FROM参加 WHERE 参加2.编号=社会团体.编号 AND 参加2.职工号=职工.职工号));
(5)GRANT SELECT,INSERT,DELEIE ON社会团体,参加TO张三WHERE GRANT OPTION;

解析: 主要考查了SQL的数据查询功能、数据定义功能和数据操纵功能。这类问题主要是考查对SELECT FROM WHERE语句的掌握。

单项选择题
填空题

When I was growing up, I was embarrassed to be seen with my father. He (1) severely crippled and very short, and when we would walk together, his hand on my arm (2) balance, people would stare. I would inwardly be afraid (3) squirm at the unwanted attention. If he ever noticed or was bothered, he never let (4) .
It was difficult to coordinate (5) steps - his halting, mine impatient - and because of that, we didn’t say much as we went along. But as we started out, he always said, "You (6) the pace. I will try to adjust to you. "
Our usual walk was to or (7) the subway, which was how he got to (8) . He went to work sick, and (9) nasty weather. He almost never missed a day, and would (10) it to the office even if (11) could not: a matter of pride!
He never talked about himself as an object of pity, (12) did he show any envy of the more fortunate or able. What he looked for in others was a "good heart", and if he found one, the owner was good enough for him.
Now that I am older, I believe that is a proper standard (13) which to judge people, even though I still don’t know precisely (14) a "good heart" is. But I know the times I don’t have one myself.
He has (15) gone many years now, but I think (16) him often. I wonder if he sensed my reluctance to be seen with him during our (17) . If he did, I am (18) I never told him how sorry I was, how unworthy I was, how I regretted it. I think of him when I complain about trifles, when I am (19) of another’s good fortune, when I don’t have a "good heart".
At such times I put my hand on his arm to regain my (20) , and say, "You set the pace, I will try to adjust to you.\