数据库练习题库

数据库练习题库
数据库练习题库

1. DBMS has many advantages. Then what are two disadvantages of database system? Answer: Two disadvantages associated with database systems are listed below.

a.Setup of the database system requires more knowledge, money, skills,

and time.

b.b. The complexity of the database may result in poor performance.

2List ?ve responsibilities of a database management system.

Ansers:

a.interaction with the ?le manager.

b.integrity enforcement.

c.security enforcement.

d.backup and recovery.

e.concurrency control.

3.What are ?ve ma in functions of a database administrator?

Answer: Five main functions of a database administrator are:

?To create the scheme de?nition

?To de?ne the storage structure and access methods

?To modify the scheme and/or physical organization when necessary ?To grant authorization for data access

?To specify integrity constraints

4.Explain the distinctions among the terms primary key, candidate key, and superkey.

Answer: A superkey is a set of one or more attributes that, taken collectively, al-lows us to identify uniquely an entity in the entity set. A superkey may contain extraneous attributes. If K is a superkey, then so is any superset of K. Asuperkey for which no proper subset is also a superkey is called a candidate key. It is possible that several distinct sets of attributes could serve as candidate keys. The primary key is one of the candidate keys that is chosen by the database designer as the principal means of identifying entities within an entity set

6.What is logical data independence and why is it important? Answer:Logical data independence means that users are shielded from changes in the logical structure of the data, i.e., changes in the choice of relations to be stored. For example, if a relation Students(sid, sname, gpa) is replaced by Studentnames(sid, sname) and Studentgpas(sid, gpa) for some reason, application programs that operate on the Students relation can be shielded from this change by de?ning a view Stu-dents(sid, sname, gpa) (as the natural join of Studentnames and Studentgpas). Thus, application programs that refer to Students need not be changed when the relation Students is replaced by the other two relations. The only change is that instead of storing Students tuples, these tuples are computed as needed by using the view de?ni tion; this is transparent to the application program.

7.Which of the following plays an important role in representing informa

tion about the real world in a database? Explain brie?y.

1. The data de?nition language.

2. The data manipulation language.

3. The bu?er manager.

4. The data model.

8 Consider the following information about a university database: Professors have an SSN, a name, an age, a rank, and a research specialty. Projects have a project number, a sponsor name (e.g., NSF), a starting date, an ending date, and a budget.

Graduate students have an SSN, a name, an age, and a degree program (e.g., M.S. or Ph.D.).

Each project is managed by one professor (known as the project?s principal investigator).

Each project is worked on by one or more professors (known as the project?s co-investigators).

Professors can manage and/or work on multiple projects.

Each project is worked on by one or more graduate students (known as the project?s research assistants).

When graduate students work on a project, a professor must supervise their work on the project. Graduate students can work on multiple projects, in which case they will have a (potentially di?erent) supervisor for each one.

Departments have a department number, a department name, and a main o?ce.

Departments have a professor (known as the chairman) who runs the department.

Professors work in one or more departments, and for each department that they work in, a time percentage is associated with their job.

Graduate students have one major department in which they are working on their degree.

Each graduate student has another, more senior graduate student (known as a student advisor) who advises him or her on what courses to take. Design and draw an ER diagram that captures the information about the university.

Use only the basic ER model here; that is, entities, relationships, and attributes. Besure to indicate any key and participation constraints.

9.Consider the university database from Exercise 8 and the ER diagram you designed. Write SQL statements to create the corresponding relations and capture as many of the constraints as possible. If you cannot capture some constraints, explain why.

Answer The following SQL statements create the corresponding relations.

1. CREATE TABLE Professors ( prof ssn CHAR(10),

name CHAR(64),

age INTEGER,

rank INTEGER,

speciality CHAR(64),

PRIMARY KEY (prof ssn) )

2. CREATE TABLE Depts ( dno INTEGER,

dname CHAR(64),

o?ce CHAR(10),

PRIMARY KEY (dno) )

3. CREATE TABLE Runs ( dno INTEGER,

prof ssn CHAR(10),

PRIMARY KEY ( dno, prof ssn),

FOREIGN KEY (prof ssn) REFERENCES Professors,

FOREIGN KEY (dno) REFERENCES Depts )

4. CREATE TABLE Work Dept ( dno INTEGER,

prof ssn CHAR(10),

pc time INTEGER,

PRIMARY KEY (dno, prof ssn),

FOREIGN KEY (prof ssn) REFERENCES Professors,

FOREIGN KEY (dno) REFERENCES Depts )

Observe that we would need check constraints or assertions in SQL to enforce the rule that Professors work in at least one department.

5. CREATE TABLE Project ( pid INTEGER,

sponsor CHAR(32),

start date DATE,

end date DATE,

budget FLOAT,

PRIMARY KEY (pid) )

6. CREATE TABLE Graduates ( grad ssn CHAR(10),

age INTEGER,

name CHAR(64),

deg prog CHAR(32),

major INTEGER,

PRIMARY KEY (grad ssn),

FOREIGN KEY (major) REFERENCES Depts )

Note that the Major table is not necessary since each Graduate has only one major

and so this can be an attribute in the Graduates table.

7. CREATE TABLE Advisor ( senior ssn CHAR(10),

grad ssn CHAR(10),

PRIMARY KEY (senior ssn, grad ssn),

FOREIGN KEY (senior ssn)

REFERENCES Graduates (grad ssn),

FOREIGN KEY (grad ssn) REFERENCES Graduates )

8. CREATE TABLE Manages ( pid INTEGER,

prof ssn CHAR(10),

PRIMARY KEY (pid, prof ssn),

FOREIGN KEY (prof ssn) REFERENCES Professors,

FOREIGN KEY (pid) REFERENCES Projects )

9. CREATE TABLE Work In ( pid INTEGER,

prof ssn CHAR(10),

PRIMARY KEY (pid, prof ssn),

FOREIGN KEY (prof ssn) REFERENCES Professors,

FOREIGN KEY (pid) REFERENCES Projects )

Observe that we cannot enforce the participation constraint for Projects in the

Work In table without check constraints or assertions in SQL.

10. CREATE TABLE Supervises ( prof ssn CHAR(10),

grad ssn CHAR(10),

pid INTEGER,

PRIMARY KEY (prof ssn, grad ssn, pid),

FOREIGN KEY (prof ssn) REFERENCES Professors,

FOREIGN KEY (grad ssn) REFERENCES Graduates,

FOREIGN KEY (pid) REFERENCES Projects )

Note that we do not need an explicit table for the Work Proj relation since everytime a Graduate works on a Project, he or she must have a Supervisor.

10. Consider the following relations:

Student(snum: integer, sname: string, major: string, level: string, age: integer)

Class(name: string, meets at: string, room: string, ?d: integer)

Enrolled(snum: integer, cname: string)

Faculty(?d: integer, fname: string, deptid: integer)

The meaning of these relations is straightforward; for example, Enrolled has one record per student-class pair such that the student is enrolled in the class.

Write the following queries in SQL. No duplicates should be printed in any of the answers.

1. Find the names of all Juniors (level = JR) who are enrolled in a class taught by I. Teach.

2. Find the age of the oldest student who is either a History major or enrolled in a course taught by I. Teach.

3. Find the names of all classes that either meet in room R128 or have ?ve or more students enrolled.

4. Find the names of all students who are enrolled in two classes that meet at the same time.

5. Find the names of faculty members who teach in every room in which some class is taught.

The answers are given below:

1. SELECT DISTINCT S.Sname

FROM Student S, Class C, Enrolled E, Faculty F

WHERE S.snum = E.snum AND https://www.360docs.net/doc/b17972710.html,ame = https://www.360docs.net/doc/b17972710.html, AND C.?d = F.?d

AND

F.fname = …I.Teach? AND S.level = …JR?

2. SELECT MAX(S.age)

FROM Student S

WHERE (S.major = …History?)

OR S.snum IN (SELECT E.snum

FROM Class C, Enrolled E, Faculty F

WHERE https://www.360docs.net/doc/b17972710.html,ame = https://www.360docs.net/doc/b17972710.html, AND C.?d = F.?d

AND F.fname = …I.Teach? )

3. SELECT https://www.360docs.net/doc/b17972710.html,

FROM Class C

WHERE C.room = (128)

OR https://www.360docs.net/doc/b17972710.html, IN (SELECT https://www.360docs.net/doc/b17972710.html,ame

FROM Enrolled E

GROUP BY https://www.360docs.net/doc/b17972710.html,ame

HA VING COUNT (*) >=5)

4. SELECT DISTINCT S.sname

FROM Student S

WHERE S.snum IN (SELECT E1.snum

FROM Enrolled E1, Enrolled E2, Class C1, Class C2 WHERE E1.snum = E2.snum AND https://www.360docs.net/doc/b17972710.html,ame <> https://www.360docs.net/doc/b17972710.html,ame AND https://www.360docs.net/doc/b17972710.html,ame = https://www.360docs.net/doc/b17972710.html,

AND https://www.360docs.net/doc/b17972710.html,ame = https://www.360docs.net/doc/b17972710.html, AND C1.meets at = C2.meets at)

5. SELECT DISTINCT F.fname

FROM Faculty F

WHERE NOT EXISTS (( SELECT *

FROM Class C )

EXCEPT

(SELECTC1.room

FROM Class C1

WHERE C1.?d = F.?d ))

1.List four signi?cant differences between a ?le-processing system and a DBMS.

Answer: Some main differences between a database management system and

a ?le-processing system are:

?Both systems contain a collection of data and a set of programswhich access that data. A database management system coordinates both the physical and the logical access to the data, whereas a ?le-processing system coordinates only the physical access.

?A databasemanagement system reduces the amount of data duplication by

ensuring that a physical piece of data is available to all programs authorized

to have access to it,whereas datawritten by one programin a ?le-processing

system may not be readable by another program.

?A database management system is designed to allow ?exible access to data

(i.e., queries), whereas a ?le-processing system is designed to allow predetermined access to data (i.e., compiled programs).

?A database management system is designed to coordinate multiple users

accessing the same data at the same time. A ?le-processing systemis usually

designed to allow one or more programs to access different data ?les at

the same time. In a ?le-processing system, a ?le can be accessed by two

programs concurrently only if both programs have read-only access to the

?le.

2Why would you choose a database system instead of simply storing data

in operating system ?les? When would it make sense not to use a database system?

Answer 1.1 A database is an integrated collection of data, usually so large that it

has to be stored on secondary storage devices such as disks or tapes. This data can

be maintained as a collection of operating system ?les, or stored in a DBMS (database

management system). The advantages of using a DBMS are:

Data independence and e?cient access. Database application programs are in-

dependent of the details of data representation and storage. The conceptual and

external schemas provide independence from physical storage decisions and logical

design decisions respectively. In addition, a DBMS provides e?cient storage and

retrieval mechanisms, including support for very large ?les, index structures and

query optimization.

Reduced application development time. Since the DBMS provides several impor-

tant functions required by applications, such as concurrency control and crash

recovery, high level query facilities, etc., only application-speci?c code needs to

be written. Even this is facilitated by suites of application development tools

available from vendors for many database management systems.

Data integrity and security. The view mechanism and the authorization facilities

of a DBMS provide a powerful access control mechanism. Further, updates to the

data that violate the semantics of the data can be detected and rejected by the

DBMS if users specify the appropriate integrity constraints.

Data administration. By providing a common umbrella for a large collection of

data that is shared by several users, a DBMS facilitates maintenance and data

administration tasks. A good DBA can e?ectively shield end-users from the chores

of ?ne-tuning the data representation, periodic back-ups etc.

Concurrent access and crash recovery. A DBMS supports the notion of a trans-

action, which is conceptually a single user?s sequ ential program. Users can write

transactions as if their programs were running in isolation against the database.

The DBMS executes the actions of transactions in an interleaved fashion to obtain

good performance, but schedules them in such a way as to ens ure that con?icting

operations are not permitted to proceed concurrently. Further, the DBMS main-

tains a continuous log of the changes to the data, and if there is a system crash,

it can restore the database to a transaction-consistent state. That is, the actions

of incomplete transactions are undone, so that the database state re?ects only the

actions of completed transactions. Thus, if each complete transaction, executing

alone, maintains the consistency criteria, then the database state after recovery

from a crash is consistent.

If these advantages are not important for the application at hand, using a collection of

?les may be a better solution because of the increased cost and overhead of purchasing and maintaining a DBMS.

3. What is logical data independence and why is it important?

Answer 1.2 Logical data independence means that users are shielded from changes in

the logical structure of the data, i.e., changes in the choice of relations to be stored.

For example, if a relation Students(sid, sname, gpa) is replaced by Studentnames(sid,

sname) and Studentgpas(sid, gpa) for some reason, application programs that operate

on the Students relation can be shielded from this change by de?ning a view Stu-

dents(sid, sname, gpa) (as the natural join of Studentnames and Studentgpas). Thus,

application programs that refer to Students need not be changed when the relation Students is replaced by the other two relations. The only change is that instead of storing Students tuples,

these tuples are computed as needed by using the view de?nition; this is transparent to the application program.

Exercise 1.5 What are the responsibilities of a DBA?

Answer 1.5 The DBA is responsible for:

Designing the logical and physical schemas, as well as widely-used portions of the

external schema.

Security and authorization.

Data availability and recovery from failures.

Database tuning: The DBA is responsible for evolving the database, in particular

the conceptual and physical schemas, to ensure adequate performance as user

requirements change.

Answer 1.7 Let us discuss the choices in turn.

The data de?nition language is important in representing information because it

is used to describe external and logical schemas.

The data manipulation language is used to access and update data; it is not

important for representing the data. (Of course, the data manipulation language

must be aware of how data is represented, and re?ects this in the constructs that

it supports.)

The bu?er manager is not very important for representation because it brings

arbitrary disk pages into main memory, independent of any data representation.

The data model is fundamental to representing information. The data model

determines what data representation mechanisms are supported by the DBMS.

The data de?nition language is just the speci?c set of language constructs available

to describe an actual application?s data in terms of the data model.

Exercise 2.4 A company database needs to store information about employees (identi?ed by ssn,with salary and phone as attrib utes), departments (identi?ed by dno, with dname and budget as attributes), and children of employees (with name and age as attributes). Employees work in departments; each department is managed by an employee; a child must be identi?ed uniquely by name when the parent (who is an employee; assume that only one parent works for the company) is known. We are not interested in information about a child once the parent leaves the company. Draw an ER diagram that captures this information.

Exercise 3.14 Consider the scenario from Exercise 2.4, where you designed an ER diagram for a company database. Write SQL statements to create the corresponding relations and capture as many of the constraints as possible. If you cannot capture some constraints, explain why.

Answer 3.14 The following SQL statements create the corresponding relations. CREATE TABLE Employees ( ssn CHAR(10),

sal INTEGER,

phone CHAR(13),

PRIMARY KEY (ssn) )

CREATE TABLE Departments ( dno INTEGER,

budget INTEGER,

dname CHAR(20),

PRIMARY KEY (dno) )

CREATE TABLE Works in ( ssn CHAR(10),

dno INTEGER,

PRIMARY KEY (ssn, dno),

FOREIGN KEY (ssn) REFERENCES Employees,

FOREIGN KEY (dno) REFERENCES Departments)

CREATE TABLE Manages ( ssn CHAR(10),

dno INTEGER,

PRIMARY KEY (dno),

FOREIGN KEY (ssn) REFERENCES Employees,

FOREIGN KEY (dno) REFERENCES Departments)

CREATE TABLE Dependents (ssn CHAR(10),

name CHAR(10),

age INTEGER,

PRIMARY KEY (ssn, name),

FOREIGN KEY (ssn) REFERENCES Employees,

ON DELETE CASCADE )

Exercise 5.1 Consider the following relations:

Student(snum: integer, sname: string, major: string, level: string, age: integer)

Class(name: string, meets at: string, room: string, ?d: integer)

Enrolled(snum: integer, cname: string)

Faculty(?d: integer, fname: string, deptid: integer)

The meaning of these relations is straightforward; for example, Enrolled has one record per student-class pair such that the student is enrolled in the class.

Write the following queries in SQL. No duplicates should be printed in any of the answers.

1. Find the names of faculty members for whom the combined enrollment of the courses that they teach is less than ?ve.

2. For each level, print the level and the average age of students for that level.

3. For all levels except JR, print the level and the average age of students for that level.

4. For each faculty member that has taught classes only in room R128, print the faculty member?s name and the total number of classes she or he has taught.

5. Find the names of students enrolled in the maximum number of classes.

6. Find the names of students not enrolled in any class.

1. SELECT DISTINCT F.fname

FROM Faculty F

WHERE 5 > (SELECT COUNT (E.snum)

FROM Class C, Enrolled E

WHERE https://www.360docs.net/doc/b17972710.html, = https://www.360docs.net/doc/b17972710.html,ame

AND C.?d = F.?d)

2. SELECT S.level, A VG(S.age)

FROM Student S

GROUP BY S.level

3. SELECT S.level, A VG(S.age)

FROM Student S

WHERE S.level <> …JR?

GROUP BY S.level

4. SELECT F.fname, COUNT(*) AS CourseCount

FROM Faculty F, Class C

WHERE F.?d = C.?d

GROUP BY F.?d, F.fname

HA VING EVERY ( C.room = …R128? )

5. SELECT DISTINCT S.sname

FROM Student S

WHERE S.snum IN (SELECT E.snum

FROM Enrolled E

GROUP BY E.snum

HA VING COUNT (*) >= ALL (SELECT COUNT (*)

FROM Enrolled E2

GROUP BY E2.snum ))

6. SELECT DISTINCT S.sname

FROM Student S

WHERE S.snum NOT IN (SELECT E.snum

FROM Enrolled E )

1. 1. Explain the fo llowing terms brie?y: attribute, domain, entity, relationship, one-to-many relationship, many-to-many relationship.

Answer 2.1 Term explanations:

Attribute - a property or description of an entity. A toy department employee

entity could have attributes des cribing the employee?s name, salary, and years of

service.

Domain - a set of possible values for an attribute.

Entity - an object in the real world that is distinguishable from other objects such

as the green dragon toy.

Relationship - an association among two or more entities.

Entity set - a collection of similar entities such as all of the toys in the toy depart-

ment.

Relationship set - a collection of similar relationships

One-to-many relationship - a key constraint that indicates that one entity can be

associated with many of another entity. An example of a one-to-many relationship

is when an employee can work for only one department, and a department can

have many employees.

Many-to-many relationship - a key constraint that indicates that many of one

entity can be associated with many of another entity. An example of a many-

to-many relationship is employees and their hobbies: a person can have many

di?erent hobbies, and many people can have the same hobby.

2. Exercise 4.2 Given two relations R1and R2, where R1 contains N1 tuples, R2con-

tains N2 tuples, and N2 > N1 > 0, give the minimum and maximum possible sizes (in

tuples) for the resulting relation produced by each of the following relational algebra expressions. In each case, state any assumptions about the schemas for R1and R2

needed to make the expression meaningful:

(1) R1∪R2, (2) R1∩R2, (3) R1?R2, (4) R1×R2, (5) σa=5(R1), (6) πa(R1),

and (7) R1/R2

Aanswer:

Exercise 2.5 Notown Records has decided to store information about musicians who perform on its albums (as well as other company data) in a database. The company has wisely chosen to hire you as a database designer (at your usual consulting fee of $2500/day).

Each musician that records at Notown has an SSN, a name, an address, and

a phone number. Poorly paid musicians often share the same address, and no address has more than one phone.

Each instrument used in songs recorded at Notown has a unique identi?cation number, a name (e.g., guitar, synthesizer, ?ute) and a musical key (e.g., C, B-?at,

E-?at).

Each album recorded on the Notown label has a unique identi?cation number, a title, a copyright date, a format (e.g., CD or MC), and an album identi?er.

Each song recorded at Notown has a title and an author.

Each musician may play several instruments, and a given instrument may be played by several musicians.

Each album has a number of songs on it, but no song may appear on more than

one album.

Each song is performed by one or more musicians, and a musician may perform a number of songs.

Each album has exactly one musician who acts as its producer. A musician may produce several albums, of course.

Design a conceptual schema for Notown and draw an ER diagram for your schema. The preceding information describes the situation that the Notown database must model. Be sure to indicate all key and cardinality constraints and any assumptions you make. Identify any constraints you are unable to capture in the ER diagram and brie?y explain why you could not express them.

Exercise 3.15 Consider the Notown database from Exercise 2.5. You have decided to recommend that Notown use a relational database system to store company data. Show the SQL statements for creating relations corresponding to the entity sets and relationship sets in your design. Identify any constraints in the ER diagram that you are unable to capture in the SQL statements and brie?y explain why you could not express them.

Answer 3.15 The following SQL statements create the corresponding relations. 1. CREATE TABLE Musicians ( ssn CHAR(10),

name CHAR(30),

PRIMARY KEY (ssn))

2. CREATE TABLE Instruments ( instrId CHAR(10),

dname CHAR(30),

key CHAR(5),

PRIMARY KEY (instrId))

3. CREATE TABLE Plays ( ssn CHAR(10),

instrId INTEGER,

PRIMARY KEY (ssn, instrId),

FOREIGN KEY (ssn) REFERENCES Musicians,

FOREIGN KEY (instrId) REFERENCES Instruments )

4. CREATE TABLE Songs Appears ( songId INTEGER,

author CHAR(30),

title CHAR(30),

albumIdenti?er INTEGER NOT NULL,

PRIMARY KEY (songId),

FOREIGN KEY (albumIdenti?er)

References Album Producer)

5. CREATE TABLE Telephone Home ( phone CHAR(11),

address CHAR(30),

PRIMARY KEY (phone),

FOREIGN KEY (address) REFERENCES Place,

6. CREATE TABLE Lives ( ssn CHAR(10),

phone CHAR(11),

address CHAR(30),

PRIMARY KEY (ssn, address),

FOREIGN KEY (phone, address)

References Telephone Home,

FOREIGN KEY (ssn) REFERENCES Musicians )

7. CREATE TABLE Place ( address CHAR(30) )

8. CREATE TABLE Perform ( songId INTEGER,

ssn CHAR(10),

PRIMARY KEY (ssn, songId),

FOREIGN KEY (songId) REFERENCES Songs,

FOREIGN KEY (ssn) REFERENCES Musicians )

9. CREATE TABLE Album Producer ( albumIdenti?er INTEGER,

ssn CHAR(10),

copyrightDate DATE,

speed INTEGER,

title CHAR(30),

PRIMARY KEY (albumIdenti?er),

FOREIGN KEY (ssn) REFERENCES Musicians )

Exercise 5.2 Consider the following schema:

Suppliers(sid: integer, sname: string, address: string)

Parts(pid: integer, pname: string, color: string)

Catalog(sid: integer, pid: integer, cost: real)

The Catalog relation lists the prices charged for parts by Suppliers. Write the following queries in SQL:

1. Find the pnames of parts for which there is some supplier.

2. Find the snames of suppliers who supply every part.

3. Find the snames of suppliers who supply every red part.

4. Find the pnames of parts supplied by Acme Widget Suppliers and no one else.

5. Find the sids of suppliers who charge more for some part than the average cost of that part (averaged over all the suppliers who supply that part).

6. For each part, ?nd the sname of the supplier who charges the most for that part. Answer 5.2 Theanswersaregivenbelow:

1. SELECT DISTINCT P.pname

FROM Parts P, Catalog C

WHERE P.pid = C.pid

2. SELECT S.sname

FROM Suppliers S

WHERE NOT EXISTS (( SELECT P.pid

FROM Parts P )

EXCEPT

( SELECT C.pid

FROM Catalog C

WHERE C.sid = S.sid ))

3. SELECT S.sname

FROM Suppliers S

WHERE NOT EXISTS (( SELECT P.pid

FROM Parts P

WHERE P.color = …Red? )

EXCEPT

( SELECT C.pid

FROM Catalog C, Parts P

WHERE C.sid = S.sid AND

C.pid = P.pid AND P.color = …Red? ))

4. SELECT P.pname

FROM Parts P, Catalog C, Suppliers S

WHERE P.pid = C.pid AND C.sid = S.sid

AND S.sname = …Acme Widget Suppliers?

AND NOT EXISTS ( SELECT *

FROM Catalog C1, Suppliers S1

WHERE P.pid = C1.pid AND C1.sid = S1.sid AND

S1.sname <> …Acme Widget Suppliers? )

5. SELECT DISTINCT C.sid

FROM Catalog C

WHERE C.cost > ( SELECT A VG (C1.cost)

FROM Catalog C1

WHERE C1.pid = C.pid )

6. SELECT P.pid, S.sname

FROM Parts P, Suppliers S, Catalog C

WHERE C.pid = P.pid

AND C.sid = S.sid

AND C.cost = (SELECT MAX (C1.cost)

FROM Catalog C1

WHERE C1.pid = P.pid)

1 List six major steps that you would take in setting up a database for a particular enterprise.

Answer: Six major steps in setting up a database for a particular enterprise are: ?De?ne the high level requirements of the enterprise (this step generates a document known as the system requirem ents speci?cation.)

?De?ne a model containing all appropriate types of data and data relation-

数据库系统概论复习题及答案

第一学期期末考试试卷和答案 试卷代码:03115 授课课时:96 课程名称:数据库系统原理A 适用对象:本科选课班 一、选择题(从下列各题四个答案中选出一个正确答案,每小题1分,共10分) 1、在数据库技术发展的几个阶段中,数据独立性最高的是__A___阶段。 A、数据库系统 B、文件系统 C、人工管理 D、数据项管理 2、在SQL的SELECT语句中,与选择运算对应的命令动词是__C___。 A、SELECT B、FROM C、WHERE D、ORDER BY 3、在数据库中,下列说法_A__是不正确的 A、数据库避免了一切数据的重复 B、若系统是完全可以控制的,则系统可确保更新是的一致性 C、数据可以共享 D、数据库减少了冗余 4、在数据库系统中,模式/外模式映像用于解决数据的_C__ A、结构独立性 B、物理独立性 C、逻辑独立性 D、分布独立性 5、关系代数的5种基本运算是__D_。 A、并、差、选择、投影、自然连接 B、并、差、交、选择、投影 C、并、差、交、选择、笛卡尔积 D、并、差、选择、投影、笛卡尔积 6、在SQL语句中,谓词“EXISTS”的含义是_B___。 A、全称量词 B、存在量词 C、自然连接--在连接条件中使用等于(=)运算符比较被连接列的列值,但它使用选择列表指出查询结果集合中所包括的列,并删除连接表中的重复列 D、等值连接--在连接条件中使用等于号(=)运算符比较被连接列的列值,其查询结果中列出被连接表中的所有列,包括其中的重复列 7、规范化过程主要为克服数据库逻辑结构中的插入异常、删除异常、更新异常以及_C__的缺陷 A、数据不一致性 B、结构不合理 C、冗余度大 D、数据丢失 8、数据库数据的正确性和相容性是数据库的__B____。 A、安全性 B、可维护性 C、完整性 D、并发控制 9、数据库三级模式体系结构主要的目标是确保数据库的_B__。 A、数据安全性 B、数据独立性

数据库原理与应用试题库

《数据库原理与应用》试题库 (附答案)

第一部分基本概念 一、单项选择题 1.在数据管理技术的发展过程中,经历了人工管理阶段、文件系统阶段和数据库系统阶段。在这几个阶段中, 数据独立性最高的是 阶段。 A.数据库系统 B.文件系统 C.人工管理 D.数据项管理 答案:A 2 。 .数据库系统与文件系统的主要区别是 A.数据库系统复杂,而文件系统简单 B.文件系统不能解决数据冗余和数据独立性问题,而数据库系统可以解决 C.文件系统只能管理程序文件,而数据库系统能够管理各种类型的文件 D.文件系统管理的数据量较少,而数据库系统可以管理庞大的数据量 答案:B 3 。 .数据库的概念模型独立于 A.具体的机器和DBMS B.E-R图 C.信息世界 D.现实世界 答案:A .数据库是在计算机系统中按照一定的数据模型 4 组织、存储和应用的 ① 支持数据库各种操作 , 的软件系统叫 ② DBMS ,由计算机、操作系统、 、数据库、应用程序及用户等组成的一个整体叫做 ③ 。 ① A.文件的集合 B.数据的集合 C.命令的集合 D.程序的集合 ② A.命令系统 B.数据库管理系统 C.数据库系统 D.操作系统 ③ A.文件系统 B.数据库系统 C.软件系统 D.数据库管理系统 答案:①B ②B ③B 5.数据库的基本特点是。 A.(1)数据可以共享(或数据结构化) (2)数据独立性 (3)数据冗余大,易移植 (4)统一管理和控制 B.(1)数据可以共享(或数据结构化) (2)数据独立性 (3)数据冗余小,易扩充 (4)统一管理和控制 C.(1)数据可以共享(或数据结构化) (2)数据互换性 (3)数据冗余小,易扩充 (4)统一管理和控制 D.(1)数据非结构化 (2)数据独立性 (3)数据冗余小,易扩充 (4)统一管理和控制 答案:B 6.数据库具有①、最小的②和较高的③。 ① A.程序结构化 B.数据结构化 C.程序标准化 D.数据模块化 ② A.冗余度 B.存储量 C.完整性 D.有效性 ③ A.程序与数据可靠性 B.程序与数据完整性 C.程序与数据独立性 D.程序与数据一致性 答案:①B ②A ③C 7.在数据库中,下列说法是不正确的。 A.数据库避免了一切数据的重复 B.若系统是完全可以控制的,则系统可确保更新时的一致性 C.数据库中的数据可以共享 D.数据库减少了数据冗余 答案:A 8.是存储在计算机内有结构的数据的集合。

数据库习题与答案

一.选择题: 1、数据库分析与设计中,其设计对象称客观世界的( ) A、逻辑对象 B、目标对象 C、实体对象 D、需求对象 答案:B (150) 2、数据库物理设计完成后,进入数据库实施阶段,下列各项中不属于实施阶段的工作就是 ( ) A、建立库结构 B、扩充功能 C、加载数据 D、系统调试 答案:B (150) 3、通常用以下的顺序来完成数据库的设计工作( ) A、概念设计、物理设计、逻辑设计 B、逻辑设计、概念设计、物理设计 C、概念设计、逻辑设计、物理设计 D、物理设计、逻辑设计、概念设计 答案:C (150) 4、在数据库设计中,在概念设计阶段可用E-R方法,其设计出的图称为( ) A、实物示意图 B、实用概念图 C、实体表示图 D、实体联系图 答案:D (153) 5、 E-R图就是数据库设计的工具之一,它适用于建立数据库的( ) A、概念模型 B、逻辑模型 C、结构模型 D、物理模型 答案:A (155) 6、在关系数据库设计中,完成设计关系模式的任务就是属于( ) A、需求分析阶段 B、概念设计阶段 C、逻辑设计阶段 D、物理设计阶段 答案:C (157) 7、数据库逻辑设计的主要任务就是( ) A、建立E-R图与说明书 B、创建数据库说明 C、建立数据流图 D、把数据送入数据库 答案:B (158) 二.填空题 1、数据库概念设计就是在数据需求分析基础上进行的,其目的就是分析数据间的内在语义 关联,在此基础上建立一个数据的______________。 答案:抽象模型(152) 2、数据库的逻辑设计的基本方法就是将E-R图转换成指定RDBMS中的______________, 此外还包括关系的规范化以及性能调整,最后就是约束条件设置。 答案:关系模式(156) 3、数据库的逻辑设计的基本方法就是将E-R图转换成指定RDBMS中的关系模式,此外还 包括______________以及性能调整,最后就是约束条件设置。 答案:关系的规范化(156) 4、数据库的逻辑设计的基本方法就是将E-R图转换成指定RDBMS中的关系模式,此外还

数据库系统应用试题及答案

数据库系统概述 一、概述 1.数据库系统是采用了数据库技术的计算机系统,数据库系统由数据库、数据库管理系统、应用系统和()。 A.系统分析员 B.程序员 C.数据库管理员 D.操作员 2.数据库(DB),数据库系统(DBS)和数据库管理系统(DBMS)之间的关系是()。 A.DBS包括DB和DBMS B.DBMS包括DB和DBS C.DB包括DBS和DBMS D.DBS就是DB,也就是DBMS 3.下面列出的数据库管理技术发展的三个阶段中,没有专门的软件对数据进行管理的是()。 I.人工管理阶段 II.文件系统阶段 III.数据库阶段 A.I 和 II B.只有 II C.II 和 III D.只有 I 4.下列四项中,不属于数据库系统特点的是()。 A.数据共享 B.数据完整性 C.数据冗余度高 D.数据独立性高 5.数据库系统的数据独立性体现在()。 A.不会因为数据的变化而影响到应用程序 B.不会因为数据存储结构与数据逻辑结构的变化而影响应用程序 C.不会因为存储策略的变化而影响存储结构 D.不会因为某些存储结构的变化而影响其他的存储结构 6.描述数据库全体数据的全局逻辑结构和特性的是()。 A.模式 B.内模式 C.外模式 D. 7.要保证数据库的数据独立性,需要修改的是()。 A.模式与外模式 B.模式与内模式 C.三级模式之间的两层映射 D.三层模式 8.要保证数据库的逻辑数据独立性,需要修改的是()。 A.模式与外模式之间的映射 B.模式与内模式之间的映射 C.模式 D.三级模式 9.用户或应用程序看到的那部分局部逻辑结构和特征的描述是()模式。 A.模式 B.物理模式 C.子模式 D.内模式 10.下述()不是DBA数据库管理员的职责。 A.完整性约束说明 B.定义数据库模式 C.数据库安全 D.数据库管理系统设计 11.概念模型是现实世界的第一层抽象,这一类模型中最著名的模型是()。 A.层次模型 B.关系模型 C.网状模型 D.实体-关系模型 <实体-联系图Entity Relationship Diagram 基本要素:实体型属性联系> 12.区分不同实体的依据是()。 A.名称 B.属性 C.对象 D.概念 13.关系数据模型是目前最重要的一种数据模型,它的三个要素分别是()。 A.实体完整性、参照完整性、用户自定义完整性 B.数据结构、关系操作、完整性约束 C.数据增加、数据修改、数据查询 D.外模式、模式、内模式 14.在()中一个结点可以有多个双亲,结点之间可以有多种联系。 A.网状模型 B.关系模型 C.层次模型 D.以上都有 15.()的存取路径对用户透明,从而具有更高的数据独立性、更好的安全保密性,也简化了程序员的工作和数据库开发建立的工作。 A.网状模型 B.关系模型 C.层次模型 D.以上都有

数据库期末试题

无锡科技职业学院 2010-2011学年第一学期 《数据库原理与应用》期末试卷20908C (09软游、09软件) 考试形式闭卷笔试+开卷机试考试时间20+100分钟 班级学号姓名成绩 I 笔试部分 该部分为闭卷,要求不得携带任何与考试有关的书和本子,考试时间为20分钟,时间到收卷,进行下一部分的考试!!! 一、选择题(20分,每题1分) 1. 数据库管理员用以下语句建立了一个新表。 CREATE TABLE emp_info( emp_ID int PRIMARY KEY, emp_Name varchar(50) UNIQUE, emp_Address varchar(50) UNIQUE) 系统在该表上自动创建________索引。 A. 复合 B. 唯一 C. 聚集 D. 非聚集 2. 使用游标处理结果集时,其基本过程不包括_________步骤。 A. 打开游标 B. 关闭游标 C. 游标嵌套 D. 释放游标 3. 默认情况下,SQL Server 2005的系统数据库有_________个。 A. 10 B. 5 C. 4 D. 6 4. 在存有数据的表上建立聚集索引,可以引起表中数据的发生变化。 A. 逻辑关系 B. 记录结构 C. 物理位置 D. 列值 5. SQL server 数据库文件有3类,其中日志文件的后缀为_________。 A. .ndf B. .ldf C. .mdf D. .idf 6. 下面语句中,_________语句用来删除视图。 A. CREATE TABLE B. ALTE VIEW C. DROP VIEW D. CREA TE VIEW 7. 对于撤销权限的不正确描述是_________。 A. 可以撤销已授予权限 B. 不能利用REVOKE语句撤销已拒绝权限 C. 可以撤销已拒绝权限 D. 可以利用REVOKE语句撤销已授予权限 8. SQL Server 2005是一个的数据库系统。 A. 网状型 B. 层次型 C. 关系型 D. 以上都不是 9. SQL Server 2005 采用的身份验证模式是。 A. 仅Windows身份验证模式 B. 仅SQL Server身份验证模式 C. 仅混合模式 D. Windows身份验证模式和混合模式

数据库原理与应用考试试题及答案

1.消除了非主属性对码的部分函数依赖的1NF的关系模式,必定是()。 A.1NF B.2NF C.3NF D.BCNF 2 .下列关于数据库恢复说法不正确的是() A.事物故障恢复采用日志文件 B.系统故障恢复采用日志文件 C.介质故障恢复采用日志文件 D.以上故障恢复均不采用日志文件 3.下面()不是常用的数据模型? A.关系模型 B.线性模型 C.层次模型 D.网状模型 4 .在数据库设计中,将E-R图转换成关系数据模型的过程属于()A.需求分析阶段B.概念设计阶段 C.逻辑设计阶段 D.物理设计阶段 5 .DBMS中实现事务持久性的子系统是() A.安全性管理子系统 B.完整性管理子系统 C.并发控制子系统 D.恢复管理子系统 6.数据库与文件系统的根本区别在于() A.提高了系统效率 B.方便了用户使用 C.数据的结构化 D.节省了存储空间 7.SQL语言是()的语言,容易学习。 A.过程化 B.非过程化 C.格式化 D.导航式 8.为了防止一个用户的工作不适当地影响另一个用户,应该采取()。 A.完整性控制 B.访问控制

C.安全性控制 D.并发控制 9.DBMS普遍采用()方法来保证调度的正确性。 A.索引 B.授权 C.封锁 D.日志 10.事务T在修改数据R之前必须先对其加X锁,直到事务结束才释放,这是()。 A.一级封锁协议 B.二级封锁协议 C.三级封锁协议 D.零级封锁协议 11.下面的选项不是关系数据库基本特征的是()。 A.不同的列应有不同的数据类型 B.不同的列应有不同的列名 C.与行的次序无关 D.与列的次序无关 12.关系模型中实现实体间N:M联系是通过增加一个()。 A.关系实现 B.属性实现 C.关系或一个属性实现 D.关系和一个属性实现 13.关系代数运算是以()为基础的运算。 A.关系运算 B.谓词演算 C.集合运算 D.代数运算 14.数据库设计可划分为七个阶段,每个阶段都有自己的设计内容,“为哪些关系,在哪些属性上、键什么样的索引”这一设计内容应该属于()设计阶段。 A.概念设计 B.逻辑设计 C.物理设计 D.全局设计 15.SQL语言中的COMMIT语句的主要作用是()。 A.结束程序 B.返回系统 C.提交事务 D.存储数据 16.一个事务的执行,要么全部完成,要么全部不做,一个事务中对数据库的所有操作都是一个不可分割的操作序列的属性是()。 A.原子性 B.一致性 C.独立性 D.持久性 17.关系的主属性不能取空值,属于()

数据库系统原理试题答案

《数据库系统原理》期中试题答案 一.选择题(每小题2分,共40分) 1.下列模型中数据抽象级别最高的是() A.概念模型B.逻辑模型 C.外部模型D.物理模型 2.设有关系R(A,B,C)和S(B,C,D),下列各关系代数表达式不成立 ...的是() (R D(S)B.S A.П C.R∪S D.ПB(R)∩ПB(S) 3.根据关系数据基于的数据模型——关系模型的特征判断下列正确的一项:(___) A.只存在一对多的实体关系,以图形方式来表示。 B.以二维表格结构来保存数据,在关系表中不允许有重复行存在。 C.能体现一对多、多对多的关系,但不能体现一对一的关系。 D.关系模型数据库是数据库发展的最初阶段。 4.下列说法错误的是() A.一个基本表可以跨一个或多个存储文件 B.一个存储文件可以跨一个或多个基本表 C.每个存储文件与外部存储器上一个物理文件对应 D.每个基本表与外部存储器上一个物理文件对应 5.在SQL语言中,数值函数COUNT(列名)用于() A.计算元组个数B.计算属性的个数 C.对一列中的非空值计算个数D.对一列中的非空值和空值计算个数 6.将弱实体转换成关系时,弱实体的主码() A.由自身的候选关键字组成B.由父表的主码组成 C.由父表的主码和自身的候选关键字组成D.不确定 7.从一个数据库文件中取出满足某个条件的所有记录的操作是() A.选择B.连接 C.投影D.复制 8.下面关于自然连接与等值连接的各个叙述中,不正确 ...的是() A.自然连接是一种特殊的等值连接 B.自然连接要求两个关系中具有相同的属性组,而等值连接不必 C.两种连接都可以只用笛卡尔积和选择运算导出 D.自然连接要在结果中去掉重复的属性,而等值连接则不必 9.SQL语言是关系数据库的标准语言,它是()

数据库期末试卷【A试卷+答案】

数媒试题 1.(V )概念模型的表示方法很多,其中最著名最为常用的是实体-联系方法。该方法用 E-R图来描述现实世界的概念模型,E-R方法也称为E-R模型。[P17] 2.(X )概念模型(E-R图),也称信息模型,它是按用户的观点来对数据和信息建模, 主要用于需求分析。【P12主要用于数据库设计】 3.(X )关系模型的操作主要包括查询、插入、删除和更新。其中的查询操作可能违背 关系的实体完整性约束条件。 【P30】【查询操作不改变表中的数据所以不可能违背实体完整性约束条件】 4.(X )数据模型的组成要素是关系数据结构、关系操作集合、关系完整性约束条件。 【关系模型的组成要素】 5.(V )在关系模型中,实体以及实体间的联系都是用二维表来表示的。【P29】 6.(X )学生(学号,姓名,性别,年龄,入校毕业年份)是规范化的关系。【P29】【关 系的每个分量必须是一个不可分割的数据项。也就是说,不允许表中还有表。】 7.(X )E-R图向数据模型转换时,多对多联系既可以转换为一个独立的关系模式,也 可以与某一端的关系模式合并。 【只能转换为一个独立的关系模式】 8.(X )在学生选课表SC(sno,cno,grade)中,同时选修了a号与b号课程同学学号的查 询语句为select sno from sc where cno=’a’ and cno=’b’。 【如此写法永远没有满足条件的元组】 9.(V )关系数据库中,关系模式是型,关系是值。关系是关系模式在某一时刻的状态 或内容。 10.(V )关系数据库模式是对关系数据库的描述,是关系数据库的型。关系数据库模式 包括:若干域的定义;在这些域上定义的若干关系模式。 11.(V )实体完整性和参照完整性是关系模型必须满足的完整性约束条件,被称作关系 的两个不变性,应该由关系系统自动支持。 12.( X ) 完整性检查和控制的对象是非法用户和非法操作,防止对数据库数据的非法存 取。【P151】【安全性控制的防范对象是非法用户和非法操作,防止对数据库数据的非法存取。】 13.(X )支持SQL的RDBMS同样支持关系数据库三级模式结构,其中模式对应部分 视图和基本表。【P81模式对应基本表】

数据库期末考试部分试题

题型:选择 第一章 题型:名词解释 题目: 1)DB 答:DB是长期存储在计算机内、有组织的、统一管理的相关数据的集合。2)DBMS 答:DBMS是位于用户与OS之间的一层数据管理软件,它为用户或应用程序提供访问DB的方法。 3)DBS 答:DBS是实现有组织地、动态地存储大量关联数据,方便多用户访问的计算机硬件、软件和数据资源组成的系统,即采用数据库技术的计算机系统。4)数据独立性 答:应用程序和DB的数据结构之间相互独立,不受影响。 5)物理独立性 答:在DB的物理结构改变时,尽量不影响应用程序。 6)逻辑独立性 答:在DB的逻辑结构改变时,尽量不影响应用程序。 题型:问答 题目: 1)人工管理阶段的数据管理有哪些特点? 答:人工管理阶段主要有4个特点:数据不保存在计算机内;没有专用的软件对数据进行管理;只有程序的概念,没有文件的概念;数据面向程序。2)文件系统阶段的数据管理有哪些特点? 答:文件系统阶段主要有5个特点:数据以“文件”形式长期保存;数据的逻辑结构与物理结构有了区别;文件组织已多样化;数据面向应用;对数据的操作以记录为单位。 3)文件系统阶段的数据管理有些什么缺陷?试取例说明。 答:主要有3个缺陷:数据冗余;数据不一致性;数据联系弱。 例如:学校里教务处、财务处、保健处建立的文件中都有学生详细资料,如联系电话、家庭住址等,这就是“数据冗余”,如果某个学生搬家,就要修改3个部门文件中的数据,否则会引起同一数据在3个部门中不一致,产生上述问题的原因是这3个部门文件中的数据没有联系。 题型:填空 题目: 1)数据管理技术的发展,与________、________和________有密切的联系。 答:硬件、软件、计算机应用 2)文件系统中的数据独立性是指________独立性。 答:设备 3)文件系统的缺陷是:________、________和________。 答:数据冗余、数据不一致、数据联系弱 4)就信息处理的方式而言,在文件系统阶段,________处于主导地位,________只起着服从程序设计需要的作用;而在数据库方式下,________占据了中心位置。

数据库试题及答案

一、单项选择题(每题0.5分,共200题,合计100分) 1. SQL Server 2008是一个( C)的数据库系统。 (A)网状型(B)层次型(C)关系型(D)以上都不是 2.关于主键描述正确的是:( C ) (A)包含一列(B)包含两列 (C)包含一列或者多列(D)以上都不正确 3. SQL Server 2008 采用的身份验证模式有(D )。 (A)仅Windows身份验证模式 (B)仅SQL Server身份验证模式 (C)仅混合模式 (D)Windows身份验证模式和混合模式 4. SQL 语言按照用途可以分为三类,下面选项中哪一种不是的:(C ) (A)DML (B)DCL (C)DQL (D)DDL 5. 在SELECT语句的WHERE子句的条件表达式中,可以匹配0个到多个字符的通配符是(B ) (A) * (B)% (C)- (D)? 6. SQL Server提供的单行注释语句是使用(B )开始的一行内容。 (A)“/*” (B)“--” (C)“{” (D)“/” 7. 以下那种类型不能作为变量的数据类型(C )。 (A)text (B)ntext (C)table (D)image 8. 下面不属于数据定义功能的SQL语句是:(C ) A.CREATE TABLE B.CREATE CURSOR C.UPDATE D.ALTER TABLE 9. 如果希望完全安装SQL Server,则应选择( A)。 A. 典型安装 B. 最小安装 C. 自定义安装 D. 仅连接 10. 在SQL SERVER中局部变量前面的字符为:(D ) (A)* (B)# (C)@@ (D) @ 11. 假如有两个表的连接是这样的: table_1 INNER JOIN table_2 其中table_1和table_2是两个具有公共属性的表,这种连接会生成哪种结果集?(D )(A)包括table_1中的所有行,不包括table_2的不匹配行 (B)包括table_2中的所有行,不包括table_1的不匹配行 (C)包括和两个表的所有行 (D)只包括table_1和table_2满足条件的行 12. 对视图的描述错误的是:(D ) (A)是一张虚拟的表 (B)在存储视图时存储的是视图的定义 (C)在存储视图时存储的是视图中的数据 (D)可以像查询表一样来查询视图 13. 在T-SQL语言中,若要修改某张表的结构,应该使用的修改关键字是(C )。(A)ALTER (B)UPDATE (C)UPDAET (D)ALLTER 14. SQL Server 2008提供了一整套管理工具和实用程序,其中负责启动、暂停和停止SQL Server的4种服务的是(D )。 (A)企业管理器(B)导入和导出数据(C)事件探察器(D)服务管理器15. 要查询book表中所有书名中以“计算机”开头的书籍的价格,可用(D )

2012年数据库系统试卷(A) 答案

华南农业大学期末考试试卷(A 卷-Answer Sheets ) 2012学年第1 学期 考试科目: Database system 考试类型:(闭卷) 考试时间: 120 分钟 学号 姓名 年级专业 Instructions to candidates: 1. Write your name, student number and class on both the question papers and the answer papers. 2. DO NOT write your answers on the question papers. Write them ALL ON THE ANSWER PAPERS. 3. Write your answers in either Chinese or English. If the answer in English is correct, you can get bonus marks. 3. Hand in all papers (both the question papers and the answer papers). Question 2 [12 marks]: (1) An invoice has attributes: Invoice#(primary key), TotalOrderAmt, Date, Terms, ShipVia. A customer has attributes: Cust#(primary key), CName, Street, City, State, Zip, Phone. A product has attributes: Prod#(primary key), StandardPrice, Description. The relationship between invoice and customer is many-to-one. One invoice can relate to only one customer, while one customer can relate to any number of invoices. The relationship between invoice and product is many-to-many. Any number of products can be placed in one invoice, and one product can appear in different invoices. The relationship between invoice and product has two attributes: SellPrice and Quantity. (2) create table Invoice

数据库应用试题一

云南师范大学成人继续教育学院商学院教学点 《数据库应用》期末试题试题(A 卷) 姓名: 学号: 系: 年级: 专业: 班级: 座号: 考试说明:1、本试卷共5页,考试时间为120分钟;2、本考试为闭卷; 3、全部试题均答在试卷上。 一、单项选择题(本大题共20小题,每小题2分,共40分) 1.关系数据库中的视图属于4个数据抽象级别中的( ) A 外部模型 B 概念模型 C 逻辑模型 D 物理模型 2.在下列关于关系的陈述中,错误的是( ) A 表中任意两行的值不能相同 B 表中任意两列的值不能相同 C 行在表中的顺序无关紧要 D 列在表中的顺序无关紧要 3.为了防止一个用户的工作不适当地影响另一个用户,应该采取( ) A 完整性控制 B 安全性控制 C 并发控制 D 访问控制 4.关系数据库中,实现实体之间的联系是通过表与表之间的( ) A 公共索引 B 公共存储 C 公共元组 D 公共属性 5.在MS SQL Server 中,用来显示数据库信息的系统存储过程是( ) A sp_ dbhelp B sp_ db C sp_ help D sp_ helpdb 6.下面系统中不属于关系数据库管理系统的是( ) A Oracle B MS SQL Server C IMS D DB2 7.SQL 语言中,删除一个表的命令是( ) A DELETE B DROP C CLEAR D REMORE 8.如果在关系的分片过程中使用了选择操作,则不可能是( ) A 水平分片 B 垂直分片 C 导出分片 D 混合分片 9.在一个实体集中,一个实体实例(一行)与另外多个实例(多行)相关,则这个实体称为( ) A 递归实体 B 弱实体 C 复合实体 D 联系实体 10.存在一个等待事务集{T 0,T 1,…,T n } ,其中T 0正等待被T 1锁住的数据项,T 1正等待被T 2锁住的数据项,T n-1正等待被T n 锁住的数据项,且T n 正等待被T 0锁住的数据项,则系统的工作状态处于( ) A 并发处理 B 封锁 C 循环 D 死锁 11.在分布式数据库中,若存取数据时只需指出片段名称,不必指出片段地址,则称系统具有( ) A 片段透明性 B 地址透明性 C 局部映象透明性 D 异地透明性 12.某学校规定,每一个班级至多有50名学生,至少有10名学生;每一名学生必须属于一

数据库SQL部分练习题集

1.SQL是_结构化查询语言__ 2.SQL语言的功能包括、__数据更新_、_ 数据查询__、。 3.视图是一个虚表,它是从______中导出的表,在数据库中,只存放视图的____,不存放视图的________。 4.设有如下关系表R:R(No,Name, Sex, Age, Class),主关键字是No,其中No为学号,Name为姓名,Sex为性别,age为年龄,Class为班号,写出实现下列功能的SQL语句。 ①插入一个记录(25,‘李明’,‘男’,21,‘95031’); _________________________________________________ ___________ ②插入‘95031’班学号为30,姓名为‘郑和’的学生记 录; _________________________________________________ ___________ ③将学号为10的学生姓名改为‘王华’; _________________________________________________ ___________ ④将所有‘95101’班号改为‘95091’; _________________________________________________ ___________ ⑤删除学号为20的学生记录;

_________________________________________________ ___________ ⑥删除姓‘王’的学生记录; _________________________________________________ ___________ 5.SQL语言是___________的语言,易学习。 A.过程化 B.非过程化 C. 格式化D.导航式 6.SQL语言是___________语言 A.层次数据库 B.网络数据库 C.关系数据库D.非数据库 7.SQL语言具有___________的功能。 A.关系规范化、数据操纵、数据控制 B.数据定义、数据操纵、数据控制 C.数据定义、关系规范化、数据控制 D.数据定义、关系规范化、数据操纵 8.SQL语言具有两种使用方式,分别称为交互式SQL和______________。 A.提示式SQL B.多用户SQL C.嵌入式SQL D.解释式SQL 9.SQL语言中,实现数据检索的语句是____________。

数据库试题及答案_

笔试样卷一 参考答案 一、简答题(25分) 1.数据库阶段数据管理的主要特点是什么? 2.解释DB、DBMS、DBS三个概念? 3.什么是物理数据独立性和逻辑数据独立性? 4.试说明DBMS的主要功能? 5.在ER模型转换为关系模型时,联系类型要根据不同的情况作不同的处理,试说明之。 二、计算题(20分) 1.设有关系R和S R: S: A B C A B C 3 6 7 3 4 5 2 5 7 7 2 3 7 3 4 4 4 3 列表计算R∪S、R-S、R×S、π 3,2(S)、δ B<5 (R)。(5分) 2.设有三个关系 S (SNO, SNAME, AGE, SEX, SDEPT) SC (SNO, CNO, GRANDE) C (CNO, CNAME, CDEPT, TNAME) 试用关系代数表达式表示下列查询

(1)检索LIU老师所授课程的课程号、课程名 (2)检索年龄大于23岁的男学生的学号和姓名 (3)检索学号为S3的学生所学课程的课程名和认课教师姓名 (4)检索WANG同学不学的课程的课程号 (5)检索至少选修了两门课程的学生的学号(10分) 三、设有三个基本表(45分) S (SNO, SNAME, AGE, SEX, SDEPT) SC (SNO, CNO, GRANDE) C (CNO, CNAME, CDEPT, TNAME) 1.试用T-SQL的查询语句表达下列查询 (1)检索LIU老师所授课程的课程号、课程名 (2)检索年龄大于23岁的男学生的学号和姓名 (3)检索学号为S3的学生所学课程的课程名和认课教师姓名 (4)检索WANG同学不学的课程的课程号 (5)检索至少选修了两门课程的学生的学号(10分) 2.试用T-SQL的查询语句表达下列查询 (1)统计有学生选修的课程的门数 (2)求选修C4课程的学生的年龄 (3)求LIU老师所授课程的每门课程的学生的平均成绩 (4)统计每门课程的学生选修人数 (5)求年龄大于所有女同学年龄的男学生的姓名和年龄(10分)3.试用T-SQL更新语句完成下列更新操作 (1)往表S中插入一个学生资料(‘S9’, ‘WU’, 18)

《数据库系统》期末考试试卷(B卷)-答案

计算机科学系《数据库系统》期末考试试卷(B 卷) (B 卷答案及评分标准) 年级:___专业:______ 班级:_ 学号:____ 姓名:______ 注:1、共120分钟,总分100分 。 1. 数据库的概念模型独立于( D )。 A.现实世界 B.E -R 图 C.信息世界 D.具体的机器与DBMS 2.下述关于数据库系统的正确叙述就是( A )。 A.数据库系统减少了数据冗余 B.数据库系统避免了一切冗余 C.数据库系统中数据的一致性就是指数据类型一致 D.数据库系统比文件系统能管理更多的数据 3.在数据库技术中,为提高数据库的逻辑独立性与物理独立性,数据库的结构被划分成用户级、( C )与存储级三个层次。 A. 管理员级 B.外部级 C.概念级 D.内部级 4.数据库管理系统就是( B )。 A.操作系统的一部分 B.在操作系统支持下的系统软件 C.一种编译程序 D.一种操作系统 5. 按所使用的数据模型来分,数据库可分为( A )三种模型。 A.层次、关系与网状 B.网状、环状与链状 C.大型、中型与小型 D.独享、共享与分时 6、 数据库系统3层结构的描述存放在( D )中。 A.数据库 B.运行日志 C.数据库管理系统 D.数据字典 7.在数据库的三级模式结构中,描述数据库中全体数据的全局逻辑结构与特征的就是( D )。 A.外模式 B.内模式 C.存储模式 D.逻辑模式 8.数据库管理系统能实现对数据库中数据的查询、插入、修改与删除等操作.这种功能称为( C )。 A.数据定义功能 B.数据管理功能 C.数据操纵功能 D.数据控制功能 9、 ( A )就是数据库系统的基础。 A.数据模型 B.数据库 C.数据库管理系统 D.数据库管理员 10、 在数据库技术中,实体-联系模型就是一种( D )。 A 、 逻辑数据模型 B 、 物理数据模型

数据库期末试卷和答案

数据库程序设计试题 1一、判断题(每题1分,共10分) 1、DB、DBMS、DBS三者之间的关系是DBS包括DB和DBMS。( ) 2、数据库的概念结构与支持其的DB的DBMS有关。( ) 3、下列式子R∩S=R—(R—S)成立。( ) 4、数据存储结构改变时逻辑结构不变,相应的程序也不变,这是数据库系统的逻辑独立 性。() 5、关系数据库基本结构是三维表。( ) 6、在嵌入式SQL语句中,主语句向SQL语句提供参数,主要用游标来实现。( ) 7、规范化的投影分解是唯一的。( ) 8、不包含在任何一个候选码中的属性叫做非主属性。( ) 9、在 Transact-SQL 语句的WHERE子句中,完全可以用IN子查询来代替OR逻辑表达式。 ( ) 10、封锁粒度越大,可以同时进行的并发操作越大,系统的并发程度越高。() 二、填空题(每空0.5分,共10分) 1、两个实体间的联系有联系,联系和联系。 2、select命令中,表达条件表达式用where子句,分组用子句,排序用 子句。 3、数据库运行过程中可能发生的故障有、和三类。 4、在“学生-选课-课程”数据库中的三个关系如下: S(S#,SNAME,SEX,AGE),SC(S#,C#,GRADE),C(C#,CNAME,TEACHER)。 现要查找选修“数据库技术”这门课程的学生姓名和成绩,可使用如下的SQL语句:SELECT SNAME,GRADE FROM S,SC,C WHERE CNAME= 数据库技术AND S.S#=SC.S# AND。 5、管理、开发和使用数据库系统的用户主要有、、 。 6、关系模型中可以有三类完整性约束:、 和。 7、并发操作带来数据不一致性包括三类:丢失修改、和。 8、事务应该具有四个属性:原子性、、隔离性和持续性。 9、数据库运行过程中可能发生的故障有事务故障、和三类。 10、在“学生-选课-课程”数据库中的三个关系如下:S(S#,SNAME,SEX,AGE),SC(S#,C#,GRADE),C(C#,CNAME,TEACHER)。 现要查找选修“数据库技术”这门课程的学生姓名和成绩,可使用如下的SQL语句:SELECT SNAME,GRADE FROM S,SC,C WHERE CNAME= ‘数据库技术’AND S.S#=SC.S# AND。 11、数据库设计包括、、逻辑结构设计、物理结构设计、数据库实施、数据库运行和维护。 12、MS SQL Server提供多个图形化工具,其中用来启动、停止和暂停SQL Server的图形 化工具称为_________。 13 、SELECT语句中进行查询 , 若希望查询的结果不出现重复元组 , 应在SELECT子 句中使用____________保留字。 14、如果一个关系不满足2NF,则该关系一定也不满足__________(在1NF、2NF、3NF 范围内)。 15、数据库的物理设计主要考虑三方面的问题:______、分配存储空间、实现存取路径。 三、单选题(每题1分,共20 分) 1、在SQL中,关系模式称为() A、视图 B、对象 C、关系表 D、存储文件 2、要保证数据库逻辑数据独立性,需要修改的是( )

整理数据库题库_数据库练习题一

数据库 JUNE 2021题库 整理人尼克 知识改变命运

数据库练习题一 一、单项选择 1.下面关于数据库设计方法的说法中错误的有() A. 数据库设计的一种方法是以信息需求为主,兼顾处理需求,这种方法称为面向数据的设计方法 B. 数据库设计的一种方法是以处理需求为主,兼顾信息需求,这种方法称为面向过程的设计方法 C. 面向数据的设计方法可以较好地反映数据的内在联系 D. 面身过程的设计方法不但可以满足当前应用的需要,还可以满足潜在应用的需求 2. 数据库技术中,独立于计算机系统的模型是() A. E/R模模型 B. 层次模型 C. 关系模型 D. 面向对象的模型 3.关于数据库设计步骤的说法中错误的有() A. 数据库设计一般分为4步:需求分析、概念设计、逻辑设计和物理设计 B. 数据库的概念模式是独立于任何数据库管理系统,不能直接用于数据库实现; C. 物理设计阶段对数据库性能影响已经很小了 D. 逻辑设计是在概念设计的基础上进行的。 4. 下面关于数据库概念设计数据模型的说法中错误的有() A. 可以方便地表示各种类型的数据及其相互关系和约束 B. 针对计算机专业人员 C. 组成模型定义严格,无多义性 D. 具有使用图形表昧概念模 5. 数据库的逻辑设计对数据的性能有一定的影响,下面的措施不能明显改善数据性能的有()。

A. 将数据库中的关系进行完全规范化; B. 将大的关系分成多个小的关系 C. 减少连接运算 D. 尽可能地使用快照 6. 一个学生可以同时借阅多本书,一本书只能由一个学生借阅,学生和图书之间为()联系。 A. 一对一 B. 一对多 C. 多对多 D. 多对一 7. 一个仓库可以存放多种零件,每一种零件可以存放在不同的仓库中,仓库和零件之间为()联系。 A. 一对一 B. 一对多 C. 多对多 D. 多对一 8. 一台机器可以加工多种零件,每一种零件可以在多台机器上加工,机器和零件之间为()联系。 A. 一对一 B. 一对多 C. 多对多 D. 多对一 9.一个公司只能有一个经理,一个经理只能在一个公司担任职务,公司和总经理职务之间为()联系。 A. 一对一 B. 一对多 C. 多对多 D. 多对一

数据库系统概论试题及答案整理版

数据库系统概论复习资料 第一章绪论 一、选择题 1.在数据管理技术的发展过程中,经历了人工管理阶段、文件系统阶段和数据库系统阶段。在这几个 阶段中,数据独立性最高的是 A 阶段。 A.数据库系B.文件系统C.人工管理D.数据项管理 2.数据库的概念模型独立于 A 。 A.具体的机器和DBMS B.E-R图C.信息世界D.现实世界 3.数据库的基本特点是 B 。 A.(1)数据结构化(2)数据独立性 (3)数据共享性高,冗余大,易移植 (4)统一管理和控制 B.(1)数据结构化(2)数据独立性 (3)数据共享性高,冗余小,易扩充 (4)统一管理和控制 C.(1)数据结构化(2)数据互换性 (3)数据共享性高,冗余小,易扩充 (4)统一管理和控制 D.(1)数据非结构化 (2)数据独立性 (3)数据共享性高,冗余小,易扩充 (4)统一管理和控制 4. B 是存储在计算机内有结构的数据的集合。 A.数据库系统B.数据库C.数据库管理系统D.数据结构 5.数据库中存储的是 C 。 A. 数据 B. 数据模型 C.数据及数据间的联系 D. 信息 6.数据库中,数据的物理独立性是指 C 。 A.数据库与数据库管理系统的相互独立 B.用户程序与DBMS的相互独立 C.用户的应用程序与存储在磁盘上数据库中的数据是相互独立的 D.应用程序与数据库中数据的逻辑结构相互独立 7.数据库的特点之一是数据的共享,严格地讲,这里的数据共享是指 D 。 A.同一个应用中的多个程序共享一个数据集合 B.多个用户、同一种语言共享数据 C.多个用户共享一个数据文件 D.多种应用、多种语言、多个用户相互覆盖地使用数据集合

sql数据库试卷

《SQL数据库管理与开发教程与实训》试题(A卷) 一、单项选择题(每小题1分,共10分) 1.下列四项中,不属于数据库特点的是()。 A.数据共享 B.数据完整性 C.数据冗余很高 D.数据独立性高 2.下列四项中,不属于SQL2000实用程序的是()。 A.企业管理器 B.查询分析器 C.服务管理器 D.媒体播放器 3.SQL Server安装程序创建4个系统数据库,下列哪个不是()系统数据库。 A.master B.model C.pub D.msdb 4.()是位于用户与操作系统之间的一层数据管理软件,它属于系统软件,它为用户或应用程序提供访问数 据库的方法。数据库在建立、使用和维护时由其统一管理、统一控制。 A.DBMS B.DB C.DBS D.DBA 5. 在SQL中,建立表用的命令是 ( )。 A.CREATE SCHEMA B.CREATE TABLE C.CREATE VIEW D.CREATE INDEX 6.SQL语言中,条件年龄 BETWEEN 15 AND 35表示年龄在15至35之间,且( )。 A.包括15岁和35岁 B.不包括15岁和35岁 C.包括15岁但不包括35岁 D.包括35岁但不包括15岁 7.下列四项中,不正确的提法是( )。 A.SQL语言是关系数据库的国际标准语言 B.SQL语言具有数据定义、查询、操纵和控制功能 C.SQL语言可以自动实现关系数据库的规范化 D.SQL语言称为结构查询语言 8.在MS SQL Server中,用来显示数据库信息的系统存储过程是( )。 A. sp_dbhelp B. sp_db C. sp_help D. sp_helpdb 9.SQL语言中,删除表中数据的命令是( )。 A. DELETE B. DROP C. CLEAR D. REMOVE 10.SQL的视图是从()中导出的。 A. 基本表 B. 视图 C. 基本表或视图 D. 数据库 二、判断题(每空1分,共10分) 1.'在那遥远的地方' 是SQL中的字符串常量吗? 2.'11.9' 是SQL中的实型常量吗 3.select 16%4, 的执行结果是: 4 吗? 4.200 5.11.09 是SQL中的日期型常量吗? 5.¥2005.89 是SQL中的货币型常量吗? 6.select 25/2 的执行结果是: 12.5 吗? 7.'岳飞'>'文天祥' 比较运算的结果为真吗? 8.一个表可以创建多个主键吗? 9.创建唯一性索引的列可以有一些重复的值? 10.固定数据库角色:db_datarader 的成员能修改本数据库内表中的数据吗? 三、填空题(每空1分,共20分) 1.数据库系统具有数据的_________、_________和内模式三级模式结构。 2.SQL Server 2000局部变量名字必须以_________开头,而全局变量名字必须以_________开头。 3.语句 select ascii('D'), char(67) 的执行结果是:_________和_________。 4.语句 select lower('Beautiful') , rtrim('我心中的太阳 ') 的执行结果是: ____________和___________。 5.选择运算是根据某些条件对关系做______分割;投影是根据某些条件对关系做______分割。 6.关系运算主要有________、________和连接。 7.完整性约束包括______完整性、______完整性、参照完整性和用户定义完整性。

相关文档
最新文档