【Introduction to Database ①】Review Question Bank

Problem Set for Introduction to Database Systems

Chapter 1 Introduction

  1. Multiple choice questions

  1. DBS is a computer system using database technology, it is a collection, including database, computer hardware, software and ( ) .

  A. System Analyst B. Programmer      C. Database Administrator        D. Operator

  2. The relationship between database (DB ), database system (DBS ) and database management system (DBMS ) is ( ).

  A. DBS includes DB and DBMS        B. DBMS includes DB and DBS

  C. DB includes DBS and DBMS D. DBS is DB, which is DBMS

  3. Among the three stages of database management technology development listed below, the one that does not have special software to manage data is ( ).

  I.Manual management phase II. File System Phase III. database stage   

A. I and II B. Only II C. II and III          D. Only I

  4. Among the following four items, the one that does not belong to the characteristics of the database system is ( ) .

  A. Data sharing B. Data integrity     C. High data redundancy --> low !           D. High data independence

  5. The data independence of the database system is reflected in ( ) .

  A. Will not affect the application due to data changes

  B. It will not affect the application program due to changes in the system data storage structure and data logic structure

  C. The storage structure will not be affected by changes in the storage strategy

  D. Will not affect other storage structures due to changes in some storage structures

  6. What describes the global logical structure and characteristics of all data in the database is ( ) .

  A. Mode        B. Internal Mode C. External Mode D. User Mode

  7. To ensure the data independence of the database, what needs to be modified is ( ) .

  A. Mode and outer mode B. Mode and inner mode        C. Two mappings between three layers     D. Three-layer mode

  8. To ensure the logical data independence of the database, what needs to be modified is ( ) .

  A. Mapping between schema and external schema     B. Mapping between schema and internal schema C. Schema D. Three-tier schema

  9. 用户或应用程序看到的那部分局部逻辑结构和特征的描述是( ),它是模式的逻辑子集。

  A.模式   B. 物理模式 C. 子模式     D. 内模式

  10.下述( )不是DBA数据库管理员的职责

  A.完整性约束说明 B. 定义数据库模式   C.数据库安全         D. 数据库管理系统设计

   选择题参考答案:(1) C  (2) A  (3) D  (4) C  (5) B  (6) A  (7) C  (8) A  (9) C  (10) D

   二、简答题

  1.试述数据、数据库、数据库系统、数据库管理系统的概念。

  数据:描述事物的符号记录称为数据。数据的种类有文字、图形、图象、声音、正文等等。数据与其语义是不可分的 。

  *解析:在现代计算机系统中数据的概念是广义的。早期的计算机系统主要用于科学计算,处理的数据是整数、实数、浮点数等传统数学中的数据等。现在计算机能存储和处理的对象十分广泛,表示这些对象的 数据也越来越复杂。

  数据与其语义是不可分的。500这个数字可以表示一件物品的价格是500元,也可以表示一个学术会议参加的人数有500人。还可以表示一袋奶粉重500克。

  数据库:数据库是长期储存在计算机内、有组织的、可共享的数据集合。数据库中的数据按一定的数据模型组织、描述和储存,具有较小的冗余度、较高的数据独立性和易扩展性,并可为各种用户共享。

  *解析:简单地讲,数据数据库数据具有永久储存、有组织和可共享三个特点。

  The data model is the core concept of the database. The data in each database is organized according to a certain data model.

  Database system: Database system (DBS) refers to the system composition after the database is introduced into the computer system. A database system consists of a database, a database management system (and its development tools), an application system, and a database administrator.

  *Analysis: Database system and database are two concepts. The database system is a man-machine system, and the database is an integral part of the database system. But in daily work, people often refer to the database system simply as the database. It is hoped that the reader will be able to distinguish between "database system" and "database" from the context of people speaking or writing. Don't be confused.

  Database Management System: A database management system (DBMS) is a layer of data management software that sits between the user and the operating system. It is used to organize and store data scientifically, acquire and maintain data efficiently. The main functions of DBMS include data definition function, data manipulation function, database operation management function, database establishment and maintenance function.

  *Analysis: DBMS is a large and complex software system. It is the basic software in the computer. At present, there are many manufacturers who specialize in the development of DBMS and the DBMS products they develop. Famous ones include DB2 relational database management system and IMS hierarchical database management system of IBM Corporation of the United States; ORACLE relational database management system of Oracle Corporation of the United States; SYBASE relational database management system of Sybase Corporation; SQL SERVER relational database management system of Microsoft Corporation of the United States, etc. .

  2. What are the benefits of using a database system?

  The benefits of using a database system are determined by the characteristics or advantages of the database management system.

  There are many benefits of using a database system, such as greatly improving the efficiency of application development, facilitating the use of users, and reducing the maintenance burden of database system managers.

  Using a database system can greatly improve the efficiency of application development. Because in the database system, the application program does not have to consider the specific path of data definition, storage and data access, all these tasks are completed by the DBMS. Using a popular metaphor, using a DBMS is like having a good staff and assistant, and many specific technical tasks are done by this assistant. Developers can focus on the design of application logic without having to worry about the many complex details of managing data.

  Also, when the application logic changes and the logical structure of the data needs to be changed, the database system provides independence between the data and the program. The change of the data logic structure is the responsibility of the DBA, and the developer does not have to modify the application program, or only needs to modify a small amount of the application program. This not only simplifies the preparation of the application program, but also greatly reduces the maintenance and modification of the application program.

  Using a database system can reduce the burden on database system administrators to maintain the system. Because the DBMS performs unified management and control on the database during the establishment, operation and maintenance of the database, including data integrity, security, multi-user concurrency control, fault recovery, etc., are all executed by the DBMS.

  In short, there are many advantages of using a database system, which not only facilitates the centralized management of data, controls data redundancy, can improve data utilization and consistency, but also facilitates the development and maintenance of application programs. Readers can combine specific applications in their future work to experience and summarize carefully.   

  3. Discuss the difference and connection between file system and database system.

  The difference between the file system and the database system: the file system is oriented to a certain application program, with poor sharing, high redundancy, and poor independence.

  The database system is oriented to the real world, with high sharing and low redundancy. It has a high degree of physical independence and certain logical independence. It is structured as a whole and described by a data model. The database management system provides data security, integrity, and concurrency Control and resilience.

  Readers can refer to the relevant content in Table 1.1 in the book "Introduction".

  The connection between the file system and the database system is: both the file system and the database system are software for managing data in the computer system.

  *Analysis:

  The file system is an important part of the operating system, while the DBMS is software independent of the operating system. But DBMS is implemented on the basis of operating system. The organization and storage of data in the database is realized through the file system in the operating system.

     Readers can have a deep understanding and a comprehensive answer to this question after further studying the relevant courses of the database management system. Because the implementation of DBMS is closely related to the file system in the operating system. For example, the basis of database implementation is files, and any operation on the database will eventually be transformed into operations on files. Therefore, the basic problem of database physical organization in DBMS implementation is how to use or how to choose the basic file organization method provided by the operating system. Here we will not go into details.

  4 . Describe the characteristics of database systems.

  The main features of a database system are:

  1. Data structure: The database system realizes the structure of the overall data , which is one of the main characteristics of the database and the essential difference between the database system and the file system.

  *Analysis: Pay attention to the word "whole" here. In the database system, the data is no longer for a certain application, but for the whole organization, with an overall structure. Not only the data is structured, but also the data access unit, that is, the size of the data that can be accessed at one time, is also very flexible. It can be as small as a certain data item (such as a student's name) or as large as a set of records (thousands of student records). In the file system, there is only one data access unit: record. Such as a student's complete record.

  2. High data sharing, low redundancy, and easy expansion : the data of the database is no longer oriented to a certain application but to the entire system, so it can be shared and used by multiple users, multiple applications, and in many different languages . Since the data is structured for the entire system, it can not only be shared by multiple applications, but also easy to add new applications, which makes the database system flexible and easy to expand.

  *Analysis:

  Data sharing can greatly reduce data redundancy, save storage space , and at the same time avoid incompatibility and inconsistency between data.

  The so-called "data for a certain application" means that the data structure is designed for a certain application and is only used by this application or application system. It can be said that data is a "private resource" of an application.

  The so-called "elasticity" means that the system is easy to expand and shrink, that is, it is not necessary to modify the structure of the entire database when the application is increased or decreased, or only a small amount of modification is required.

  We can take various subsets of the overall data for different application systems. When the application requirements change or increase, we only need to re-select different subsets or add some data to meet the new requirements.   

  3. High data independence : Data independence includes physical independence of data and logical independence of data. The schema structure and secondary image function of the database management system ensure that the data in the database have high physical and logical independence.

  *Analysis:

  The so-called "independence" is not dependent on each other. Data independence means that data and programs do not depend on each other. That is, if the logical structure or physical structure of the data changes, the program will not change accordingly. The independence of data and program separates the definition of data from the program, and the DBMS is responsible for data access, which simplifies the compilation of application programs and greatly reduces the maintenance and modification of application programs.  

  Fourth, the data is managed and controlled by the DBMS: the sharing of the database is concurrent sharing, that is, multiple users can simultaneously access the data in the database or even access the same data in the database at the same time. To this end, DBMS must provide unified data control functions, including data security protection, data integrity check, concurrency control and database recovery.

  *Analysis:

  The DBMS data control function includes four aspects:

  Data security protection: protect data to prevent data leakage and destruction caused by illegal use;

  Data integrity check: control the data within the valid range or ensure that the data satisfy a certain relationship;

  Concurrency control: control and coordinate the concurrent operations of multiple users to ensure the correctness of concurrent operations;

  Database recovery: When the computer system has a hardware failure, software failure, or due to operator error or intentional damage, the correctness of the data in the database is affected, and even part or all of the data in the database is lost, the database can be restored from the wrong state to the original state. A known correct state (also known as a complete state or a consistent state).

  Below we can get a definition of "what is a database":

   A database is a large collection of shared data that is organized and stored in a computer . It can be shared by various users with minimal redundancy and high data independence. DBMS controls the database in a unified manner during the establishment, operation and maintenance of the database to ensure the integrity and security of the data, and controls the concurrency when multiple users use the database at the same time, and restores the system after a failure occurs.

  The emergence of the database system makes the information system shift from the program centered on processing data to a new stage centered around the shared database.  

  5 . What are the main functions of a database management system?

  ①Database definition function;

  ② Data access function;

  ③Database operation management;

  ④ database establishment and maintenance functions.

  6 . Describe the concept of the data model, the function of the data model and the three elements of the data model.

  The data model is a tool used in the database to abstract the real world, and a formal framework used to provide information representation and operation means in the database.

  Generally speaking, a data model is a collection of strictly defined concepts. These concepts precisely describe the static characteristics, dynamic characteristics and integrity constraints of the system. Therefore, the data model usually consists of three parts: data structure, data operation and integrity constraints.

  ① Data structure: It is a collection of object types under study, and it is a description of the static characteristics of the system.

  ②Data operation: refers to the collection of operations allowed to be performed on instances (values) of various objects (types) in the database, including operations and related operation rules, and is a description of the dynamic characteristics of the system.

  ③Data constraints: It is a collection of integrity rules. Integrity rules are the constraints and dependency rules of data and their connections in a given data model, which are used to limit the state of the database conforming to the data model and the changes of the state. Ensure the correctness, effectiveness and compatibility of data.

  *Analysis:

  Data model is one of the most important concepts in database system. Students must truly master the

  The concept and function of data model.

  A data model is the foundation of a database system. Any DBMS is based on a certain data model, or supports a certain data model.

  There are different levels of models in a database system. According to the different purposes of model application, the model can be divided into two categories or two levels: one is the conceptual model, which models data and information according to the user's point of view, and is used for modeling the information world, emphasizing the ability of semantic expression, The concept is simple and clear; the other is the data model, which models data from the point of view of a computer system and is used in the machine world. People can use it to define and manipulate data in the database. Generally, a strict formal definition and a set of languages ​​with strictly defined syntax and semantics are required, and there are some regulations and restrictions, which are convenient for machine implementation.

  7 . Describe the role of conceptual models.

  The conceptual model is actually an intermediate level from the real world to the machine world. The conceptual model is used to model the information world. It is the first layer of abstraction from the real world to the information world. It is a powerful tool for database designers to design databases and a language for communication between database designers and users.

  8 . Define and explain the following terms in the conceptual model:

  Entity, Entity Type, Entity Set, Attribute, Code, Entity Relationship Diagram (ER Diagram)

  Entity: Things that exist objectively and can be distinguished from each other are called entities.

  Entity type: Entities with the same attributes have the same characteristics and properties. Using entity names and their attribute name sets to abstract and describe similar entities is called entity type.

  Entity Set: A collection of entities of the same type is called an entity set.

  Attribute: A certain characteristic of an entity. An entity can be characterized by several attributes.

  Code: The set of attributes that uniquely identify an entity is called a code.

  Entity Relationship Diagram: ER diagrams provide a way to represent entity types, attributes, and relationships:

  · Entity type: It is represented by a rectangle, and the entity name is written in the rectangle box.

  · Attributes: Represented by ellipses and connected with corresponding entities by undirected edges.

  ·Contact: Represented by a rhombus, the name of the contact is written in the rhombus box, and the undirected edges are respectively connected with the relevant entities, and the type of the connection (1 : 1, 1 : n or m : n) is marked beside the undirected edges .

relational database

  1. Multiple choice questions

  1. The following option is not a basic feature of a relational database ( ).

  A. Different columns should have different data types  B. Different columns should have different column names

  C. Has nothing to do with the order of the rows D. Has nothing to do with the order of the columns

  2. There is only one ( ) in a relation .

  A. Candidate code B. Outer code C. Super code        D. Main code

  3. In the relational model, a key is ( ).

  A. It can be composed of multiple arbitrary attributes B. It can be composed of at most one attribute

  C. There can be multiple or one attribute whose value can uniquely represent any tuple in the relational schema       D. None of the above

  4. The existing relationship is as follows:

  Patient (patient number, patient name, gender, date of birth, unit)

  Medical (patient number, patient name, doctor number, doctor name, diagnosis date, diagnosis result)

  Among them, the outer key in the medical relationship is ( ).

  A. Patient ID        B. Patient Name C. Patient ID and Patient Name D. Physician ID and Patient ID

  5. There is a relationship: borrowing (book number, book title, inventory, reader number, loan period, repayment period), if the same book allows a reader to borrow multiple times, but cannot borrow multiple copies of a book at the same time, then The outer code of this relational pattern is ( ).

  A. Book number B. Reader number C. Book number + reader number       D. Book number + reader number + loan period

  6. In the relationship model, the N :M connection between entities is realized by adding a ( ) .

  A. Relationship realization   B. Property realization C. Relationship or one property realization D. Relationship and one property realization

  7. Relational algebra operations are operations based on ( ) .

  A. Relational operations B. Predicate calculus C. Set operations        D. Algebraic operations

  8. The specialized relational operations that the relational database management system should be able to implement include ( ).

  A. Sorting, Indexing, Statistics    B. Selecting, Projecting, Joining       C. Associating, Updating, Sort D. Displaying, Printing, Tabulating

  9. The five basic relational algebra operations are ( ). ?

  A. × σ π       B.∪ - σ π   C. × σ π   D.∪ ∩ σ π

  10. In the optimization strategy of relational algebra expressions, the first thing to do is ( ) .

  A. Preprocess the file   B. Perform selection operation as early as possible   C. Perform Cartesian product operation D. Projection operation

  11. The projection operation in the relational database refers to ( ) from the relation .

  A.抽出特定记录          B. 抽出特定字段   C.建立相应的影像       D. 建立相应的图形

  12. 从一个数据库文件中取出满足某个条件的所有记录形成一个新的数据库文件的操作是( )操作

  A.投影          B. 联接        C. 选择        D. 复制

  13. 关系代数中的联接操作是由( )操作组合而成

  A.选择和投影             B. 选择和笛卡尔积   C.投影、选择、笛卡尔积       D. 投影和笛卡尔积

  14. 自然联接是构成新关系的有效方法。一般情况下,当对关系R和S是用自然联接时,要求R和S含有一个或者多个共有的(

  A.记录          B. 行            C. 属性        D. 元组

  15. Assuming that there are relations R and S , in the following relational operations, the ( ) operation does not require: "R and S have the same arity, and the data types of their corresponding attributes are also the same" .

  A.R∩S         B. R∪S        C. R-S        D. R×S

  16. Assuming that there are relations R and S , the relational algebra expression R - (R - S ) represents ( ).

  A.RS         B. R∪S        C. R-S        D. R×S

  17. Among the relational algebra expressions listed below, those expressions can be established ( ) .

  ⅰ. σf1 ( σf2 (E)) = σf1∧f2 (E)

  ⅱ. E1∞E2 = E2∞E1

  ⅲ. (E1∞E2)∞E3 = E1∞ (E2∞E3)

  ⅳ. σf1 ( σf2 (E)) =σf2 ( σf1(E))

  A. All B. ii and ⅳ     C. None        D. ⅰ and ⅳ

  18. The following four relational expressions are equivalent, which is to judge their execution efficiency ( ) .

  E1 =πA (σ B=C ∧ D=E′ (R×S) )

  E2 =πA (σ B=C (R× σD=E′ (S) )

  E3 =πA (R∞B=CσD=E′(S) )

  E3 =πA (σD=E′ (R∞B=CS) )

  A. E3 is the fastest    B. E2 is the fastest C. E4 is the fastest D. E1 is the fastest

  19. There is a relationship SC (S_ID , C_ID , AGE , SCORE ), to find the student number and score of students older than 22 years old, the correct relational algebra expression is ( ) .

  ⅰ. πS_ID,SCORE (σ age>22 (SC) )

  ⅱ. σ age>22 (πS_ID,SCORE (SC) )

  ⅲ. πS_ID,SCORE (σ age>22 (πS_ID,SCORE,AGE (SC) ) )

  A. i and ii B. only ii is correct C. only i is correct          D. i and iii are correct

    Reference answer for multiple choice questions: (1) A (2) D (3) C (4) A (5) D (6) A (7) C (8) B (9) A (10) B

(11) B (12) C (13) B (14) C (15) D (16) A (17) C (18) A (19) D

   2. Short answer questions

  1. Describe the three components of the relational model.

  2. Describe the characteristics and classification of relational data languages.

  3. There is an SPJ database, including S , P , J , and SPJ four relational schemas:

   S( SNOSNAMESTATUSCITY)

   P(PNOPNAMECOLORWEIGHT)

   J(JNOJNAMECITY)

  SPJ(SNO PNO JNO QTY)

  Supplier table S is composed of supplier code ( SNO ), supplier name ( SNAME ), supplier status ( STATUS ), supplier city ( CITY ); part table P is composed of part code ( PNO ), part name ( PNAME ) , color ( COLOR ), weight ( WEIGHT ); project table J is composed of project code ( JNO ), project name ( JNAME ), project city ( CITY ); supply situation table SPJ is composed of supplier code ( SNO ), part code ( PNO ), engineering item code ( JNO ), and supply quantity ( QTY ), indicating that the quantity of a certain part supplied by a supplier to a certain engineering project is QTY .

  Use relational algebra to complete the following query:

  ( 1 ) Seek the supplier number SNO for supplying J1 parts of the project ;

  ( 2 ) Find the supplier number SNO of the part P1 of the supply project J1 ;

  ( 3 ) Ask for the supplier number SNO of the supplier whose J1 parts are red in supply engineering ;

  ( 4 ) Find the engineering number JNO of the red parts produced by the supplier in Tianjin ;

  ( 5 ) Find the engineering number JNO that uses at least all parts supplied by supplier S1 .

  4. Define and understand the following terms, explaining the connection and difference between them:

   (1) Domain, Cartesian product, relation, tuple, attribute

   (2) Main key, candidate key, outer key

   (3) Relational schema, relational, relational database

  5. State the integrity rules of the relational model. In referential integrity, why can the value of the foreign key attribute be empty sometimes? Under what circumstances can it be empty?

  6. Discuss the difference and connection between equivalence join and natural join.

  7. What are the basic operations of relational algebra?

8. Use the basic operations of relational algebra to represent other operations.

3 SQL language

  1. Multiple choice questions

  1. The SQL language is a language of ( ), easy to learn .

  A. Procedural      B. Non-procedural   C. Formatting D. Navigation

  2. Data manipulation statements in SQL language include SELECT , INSERT , UPDATE , DELETE, etc. The most important and most frequently used statement is ( ) .

  A. SELECT   B. INSERT   C. UPDATE      D. DELETE

  3. The operation that cannot be done on the view is ( ) .

  A. update view B. query   C. define new table on view     D. define new view on view

  4. The SQL language integrates data query, data manipulation, data definition, and data control functions. Among them, which function is realized by the CREATE , DROP , and ALTER statements ( ).

  A. Data query        B. Data manipulation   C. Data definition D. Data control

  5. In the SQL language, the command to delete a view is ( ).

  A.DELETE      B.DROP   C.CLEAR        D.REMOVE

  6. The view VIEW in the SQL language is the ( ) of the database .

  A. External mode             B. Mode        C. Internal mode              D. Storage mode

  7. Among the following SQL statements, ( ) is not a data definition statement.

  A. CREATE TABLE     B. DROP VIEW   C. CREATE VIEW   D. GRANT

  8. If you want to revoke the existing table S in the database , you can use ( ).

  A. DELETE TABLE S (-->delete from s)     B. DELETE S   C. DROP TABLE S      D. DROP S

  9. To add a column of CN (course name) to the basic table S , use ( ).

  A.ADD TABLE S(CN CHAR(8))       B.ADD TABLE S ALTER(CN CHAR(8))

  C.ALTER TABLE S ADDCN CHAR(8)) D.ALTER TABLE S (ADD CN CHAR(8))

  10. The student relationship model S ( S #, Sname , Sex , Age ), the attributes of S respectively represent the student's student number, name, gender, and age. To delete an attribute "age" in table S , the optional SQL statement is ( ).

  A. DELETE Age from S       B. ALTER TABLE S DROP Age

  C. UPDATE S Age               D. ALTER TABLE S ‘Age’

  11. There are relations S (S #, SNAME , SAGE ), C (C #, CNAME ), SC (S #, C #, GRADE ). Where S # is the student number, SNAME is the student name, SAGE is the student age, C # is the course number, and CNAME is the course name. The SQL statement to query the names of all students whose age is not less than 20 who have taken the course "ACCESS" is the SELECT SNAME FROM S , C , SC WHERE clause. The content of the WHERE clause here is ( ).

  A. S.S# = SC.S# and C.C# = SC.C# and SAGE>=20 and CNAME=‘ACCESS’

  B. S.S# = SC.S# and C.C# = SC.C# and SAGE in>=20 and CNAME in ‘ACCESS’

  C. SAGE in>=20 and CNAME in ‘ACCESS’

  D. SAGE>=20 and CNAME=’ ACCESS’

  12. Let the structure of a table S in the relational database be S (SN , CN , grade ), where SN is the name of the student, CN is the name of the course, both of which are character types; -100 . If you want to insert "Zhang Er's chemistry score is 80 points" into S , you can use ( ).

  A. ADD INTO S VALUES('Zhang Er','Chemistry','80')

  B. INSERT INTO S VALUES('Zhang Er','Chemistry','80')

C. ADD INTO S VALUES('Zhang Er','Chemistry',80)

D. INSERT INTO S VALUES('Zhang Er','Chemistry',80)

  13. Let the structure of a table S in the relational database be: S (SN , CN , grade ), where SN is the student name, CN is the course name, both of which are character types; grade is the grade, numerical type, and the value range 0-100 . _ If you want to correct Wang Er's chemistry score to be 85 , you can use ( ) .

  A. UPDATE S SET grade=85 WHERE SN='Wangji' AND CN='Chemistry'

  B. UPDATE S SET grade='85'WHERE SN='Wangji' AND CN='Chemistry'

  C. UPDATE grade=85 WHERE SN=’王二’ AND CN=’化学’

  D. UPDATE grade=’85’WHERE SN=’王二’ AND CN=’化学’

  14. 在SQL语言中,子查询是(

  A. 返回单表中数据子集的查询语言

  B. 选取多表中字段子集的查询语句

  C. 选取单表中字段子集的查询语句

  D. 嵌入到另一个查询语句之中的查询语句

  15. SQL是一种( )语言。

  A. 高级算法        B. 人工智能   C. 关系数据库      D. 函数型

  16. 有关系S(S#,SNAME,SEX),C(C#,CNAME),SC(S#,C#,GRADE)。其中S#是学生号,SNAME是学生姓名,SEX是性别, C#是课程号,CNAME是课程名称。要查询选修“数据库”课的全体男生姓名的SQL语句是SELECT SNAME FROM S,C,SC WHERE子句。这里的WHERE子句的内容是( )。

  ASS# = SC.S# and CC# = SC.C# and SEX='Male' and CNAME='Database'

  BSS# = SC.S# and CC# = SC.C# and SEX in 'Male' and CNAME in 'Database'

  C.SEX 'male' and CNAME 'database'

  DSSEX='Male' and CNAME='Database'

  17. If a table SC is created with the following SQL statement :

  CREATE TABLE SC (S# CHAR (6 ) NOT NULL , C# CHAR (3 ) NOT NULL , SCORE INTEGER , NOTE CHAR (20 )); When inserting the following rows into the SC table, ( ) rows can be inserted .

  A. ('201009', '111', 60, required) B. ('200823', '101', NULL, NULL)

  C.(NULL,'103',80,'Elective') D.('201132',NULL,86,' ')

  18. Suppose student relationship S (S #, SNAME , SEX ), course relationship C (C #, CNAME ), student selection relationship SC (S #, C #, GRADE ). To query the names of boys who have taken the course "Computer ", the relationship ( ) will be involved .

            A. S       B. S,SC       C. C,SC      D. S,C,SC

   Multiple choice questions reference answer : (1) B (2) A (3) C (4) C (5) B (6) A (7) D (8) C (9) C (10) B

  (11) A (12) D (13) A (14) D (15) C (16) A (17) B (18) D

  2. Short answer questions

  1. Describe the characteristics of the SQL language.

  Answer: (1) Comprehensive and unified. The SQL language integrates the functions of data definition language DDL, data manipulation language DML, and data control language DCL.

  (2) Highly non-procedural. To operate data with SQL language, you only need to propose "what to do" instead of "how to do it", so you don't need to know the access path, the selection of access path and the operation process of SQL statement are automatically completed by the system.

  (3) Set-oriented operation mode. The SQL language adopts the set operation mode, not only the operation object and the search result can be a set of tuples, but also the object of an insert, delete, and update operation can also be a set of tuples.

  (4) Provide two usage methods with the same grammatical structure. The SQL language is both a self-contained language and an embedded language. As a self-contained language, it can be used independently for online interactive use, and can also be embedded in high-level language programs for programmers to use when designing programs.

  (5) The language is simple and easy to learn and use.

   2. Try to describe the definition function of SQL .

  Answer: The data definition function of SQL includes defining tables, defining views, and defining indexes.

   The SQL language uses the CREATE TABLE statement to define the basic table; the ALTER TABLE statement modifies the basic table definition, and the DROP TABLE statement deletes the basic table; the index uses the CREATE INDEX statement to build the index, and the DROP INDEX statement deletes the index table; the SQL language uses the CREATE VIEW command to establish View, the DROP VIEW statement deletes a view.

   3. Create the four tables in Exercise 3 of Chapter 3 with SQL statements.

  Answer: For S table: S(SNO, SNAME, STATUS, CITY);

   建S表:CREATE TABLE S(SNO CHAR(3),SNAME CHAR(10),STATUS CHAR(2),CITY CHAR(10));

   P(PNO,PNAME,COLOR,WEIGHT);

   建P表:CREATE TABLE P (PNO CHAR(3),PNAME CHAR(10),COLOR CHAR(4),WEIGHT INT);

   J(JNO,JNAME,CITY);

   建J表:CREATE TABLE J(JNO CHAR(3),JNAME CHAR(10),CITY CHAR(10));

   SPJ(SNO,PNO,JNO,QTY);

   建SPJ表:CREATE TABLE SPJ(SNO CHAR(3),PNO CHAR(3),JNO CHAR(3),QTY INT);

  4. Use SQL language to complete the query in Chapter 3 Exercise 3 for the four tables created in the above question .

  Answer: (1) Ask for the supplier number SNO of the J1 parts of the supply project;

   SELECT SNO

   FROM SPJ

   WHERE JNO=‘J1’;

  (2) Ask for the supplier number SNO of the part P1 of the supply project J1;

   SELECT SNO

   FROM SPJ

   WHERE JNO=‘J1’

   AND PNO='P1';

  (3) Ask for the supplier number SNO of the supplier whose J1 parts are in red;

   SELECT SNO

   FROM SPJ

   WHERE JNO=‘J1’

   AND PNO IN

   (SELECT PNO

   FROM P

   WHERE COLOR=‘红’);

   or

   SELECT SNO

   FROM SPJ,P

   WHERE JNO=‘J1’

   AND SPJ.PNO=P.PNO

   AND COLOR=‘红’;

  (4) Ask for the engineering number JNO of the red parts produced by suppliers in Tianjin who are not used;

  Parse:

   Expressed in SQL language as follows:

   SELECT JNO

   FROM J

   WHERE NOT EXISTS

   (SELECT *

   FROM SPJ

   WHERE SPJ.JNO=J.JNO

   AND SNO IN

   (SELECT SNO

   FROM S

   WHERE CITY='Tianjin')

   AND PNO IN

   (SELECT PNO

   FROM P

   WHERE COLOR=‘红’));

   or

   SELECT JNO

   FROM J

   WHERE NOT EXISTS

   (SELECT *1

   FROM SPJ, S, P

   WHERE SPJ.JNO=J.JNO

   AND SPJ.SNO=S.SNO

   AND SPJ.PNO=P.PNO

   AND S.CITY='Tianjin'

   AND P. COLOR=‘红’);

   NOTE: Start with the J table to include those engineering numbers that have not used any parts.

  (5) Find the project number JNO that uses at least all parts supplied by supplier S1.

  Parse:

  Expressed in SQL language as follows:

   SELECT DISTINCT JNO

   FROM SPJ SPJZ

   WHERE NOT EXISTS

   (SELECT *

   FROM SPJ SPJX

   WHERE SNO='S1'

   AND NOT EXISTS

   (SELECT *

   FROM SPJ SPJY

   WHERE SPJY.PNO=SPJX.PNO

   AND SPJY.JNON=SPJZ.JNO

   AND SPJY.SNO=’S1’));

   AND SPJY.SNO='S1' ));

  

  5. Use the SQL language to complete the following operations on the four tables in exercise 3 :

   (1) Find out the names and cities of all suppliers.

   (2) Find out the names, colors, and weights of all parts.

   (3) Find out the project number using the part supplied by supplier S1.

   (4) Find out the names and quantities of various parts used in project J2.

   (5) Find out all part numbers supplied by Shanghai manufacturers.

   (6) Find out the name of the project using the parts produced in Shanghai.

   (7) Find out the project numbers that do not use parts produced in Tianjin.

   (8) Change the color of all red parts to blue.

   (9) The part P6 supplied by S5 to J4 is changed to be supplied by S3, please make necessary modifications.

   (10) Delete the record of S2 from the supplier relationship and delete the corresponding record from the supply situation relationship.

   (11) Please insert (S2, J6, P4, 200) into the supply situation relationship.

   Answer: (1) Find out the names and cities of all suppliers.

   SELECT SNAME, CITY

   FROM S;

   (2) Find out the name, color, weight of all parts.

   SELECT PNAME, COLOR, WEIGHT

   FROM P;

   (3) Find out the project number using the parts supplied by supplier S1.

   SELECT JNO

   FROM SPJ

   WHERE SNO=‘S1’;

   (4) Find out the names and quantities of various parts used in project J2.

   SELECT P.PNAME, SPJ.QTY

   FROM P, SPJ

   WHERE P.PNO=SPJ.PNO

   AND SPJ.JNO='J2';

   (5) Find out all the part numbers supplied by the manufacturers in Shanghai.

   SELECT DISTINCT PNO

   FROM SPJ

   WHERE SNO IN

   (SELECT SNO

   FROM S

   WHERE CITY='Shanghai');

   (6) Find out the name of the project using the parts produced in Shanghai.

   SELECT JNAME

   FROM J, SPJ, S

   WHERE J. JNO=SPJ. JNO

   AND SPJ. SNO=S.SNO

   AND S.CITY='Shanghai';

   or

   SELECT JNAME

   FROM J

   WHERE JNO IN

   (SELECT JNO

   FROM SPJ, S

   WHERE SPJ. SNO=S.SNO

   AND S.CITY='Shanghai');

   (7) Find out the project numbers that do not use parts made in Tianjin.

   SELECT JNO

   FROM J

   WHERE NOT EXISTS

   (SELECT *

   FROM SPJ

   WHERE SPJ.JNO=J.JNO AND SNO IN

   (SELECT SNO

   FROM S

   WHERE CITY='Tianjin'));

   or

   SELECT JNO

   FROM J

   WHERE NOT EXISTS

   (SELECT *1

   FROM SPJ, S

   WHERE SPJ.JNO=J.JNO AND SPJ.SNO=S.SNO AND S.CITY=‘天津’);

   (8) Change the color of all red parts to blue.

   UPDATE P

   SET COLOR='blue'

   WHERE COLOR='红' ;

   (9) The part P6 supplied by S5 to J4 is changed to be supplied by S3, please make necessary modifications.

   UPDATE SPJ

   SET SNO='S3'

   WHERE SNO='S5' AND JNO='J4' AND PNO='P6';

   (10) Delete the record of S2 from the supplier relationship and delete the corresponding record from the supply situation relationship.

   DELETE

   FROM SPJ

   WHERE SNO='S2';

   or

   DELETE

   FROM S

   WHERE SNO='S2';

  Analysis: Pay attention to the order of deletion, the records of the parts supplied by supplier S2 should be deleted from the SPJ table first, and then S2 should be deleted from the S table.

   (11) Please insert (S2, J6, P4, 200) into the supply situation relation.

   INSERT INTO SPJ(SNO, JNO, PNO, QTY)

   VALUES (S2,J6,P4,200);

   or

   INSERT INTO SPJ

   VALUES (S2,P4,J6,200);

  6. What is a basic table? What is a view? What is the difference and connection between the two?

  Answer: The basic table is a table that exists independently. In SQL, a relationship corresponds to a table.

  Views are tables derived from one or several base tables. The view itself is not stored independently in the database, it is a virtual table. That is, only the definition of the view is stored in the database without the data corresponding to the view, and these data are still stored in the basic table of the exported view. Views are conceptually equivalent to basic tables. Users can use views like basic tables, and can redefine views on views.

  7. Discuss the advantages of views.

  Answer: (1) The view can simplify the user's operation.

   (2) Views enable users to look at the same data from multiple perspectives.

   (3) The view provides a certain degree of logical independence for refactoring the database.

   (4) View can provide security protection for confidential data.

  8. Can all views be updated? Why?

  Answer: No. Views are virtual tables that do not actually store data, so updates to views are ultimately converted to updates to basic tables. Not all views are updatable because updates to some views do not uniquely and meaningfully translate into updates to the corresponding base tables. Such as the view S_G in "Introduction" 3.5.1 (student's student number and his average grade)

   CREAT VIEW S_G(Sno,Gavg)

   AS SELECT Sno,AVG(Grade)

   FROM SC

   GROUP BY Sno;

  To modify the grade point average, individual subject grades must be revised, and we have no way of knowing which course grade changes caused the grade point average to change.

  9. Which types of views can be updated and which types of views cannot be updated? Give an example of each.

  Answer: The row-column subset view of the basic table is generally updatable. Such as Example 1 in 3.5.3 of "Introduction".

  If the attributes of the view come from set functions and expressions, the view must not be updated.

  Such as the S_G view in 3.5.3 of "Introduction".

  10. Describe the rules for updating views in an actual system you are familiar with.

  Answer: (omitted)

  Analysis: Different systems have different regulations on view updates, and readers must understand the regulations on view updates in the system you use.

  11. Please create a supply situation view for the three construction projects, including supplier code (SNO), parts

  Code (PNO), Quantity to Supply (QTY). Complete the following query against the view:

   (1) Find out the codes and quantities of various parts used in the three construction projects.

   (2) Find out the supply situation of supplier S1.

  Answer: Create a view:

   CREATE VIEW V_SPJ AS

   SELECT SNO, PNO, QTY

   FROM SPJ

   WHERE JNO=

   (SELECT JNO

   FROM J

   WHERE JNAME='three construction');

   Query the view:

   (1) Find out the various part codes and their quantities used in the three construction projects.

   SELECT PNO, QTY

   FROM V_SPJ;

   (2) Find out the supply situation of supplier S1.

   SELECT PNO, QTY /* S1 supplies the part number and corresponding quantity of the three construction projects*/

   FROM V_SPJ

   WHERE SNO='S1';

4Database Security

  1. Multiple choice questions

  1. The following ( ) do not belong to the main technologies and methods to realize the security of the database system.

  A. Access control technology B. View technology C. Audit technology D. Registration and locking in and out of the computer room

  2 . Views in SQL improve the ( ) of the database system.

  A. Integrity B. Concurrency control C. Isolation D. Security

  3 . The GRANT and REMOVE statements of the SQL language are mainly used to maintain the database ( ).

  A. Integrity B. Reliability C. Security D. Consistency

  4. In the security control of the database, the authorized data object ( ), the more flexible the authorization subsystem.

  A. The smaller the scope B. The more detailed the constraints C. The larger the scope D. The larger the constraints

  Multiple Choice Answers:

  (1) D (2) D (3) C (4) A

  3. Short answer questions

  1. What is database security?

  Answer: The security of the database refers to the protection of the database to prevent data leakage, alteration or destruction caused by illegal use.

  2. What is the relationship between database security and computer system security?

  Answer: Security issues are not unique to database systems, all computer systems have this issue. It is just that a large amount of data is stored centrally in the database system and is directly shared by many end users, which makes the security problem more prominent.

  Whether the system security protection measures are effective is one of the main indicators of the database system.

  The security of the database and the security of the computer system, including the security of the operating system and the network system, are closely related and mutually supportive.

  3. Try to describe the common methods and technologies to realize database security control.

  Answer: Common methods and technologies to implement database security control are:

  1) User identification and authentication: In this method, the system provides a certain way for users to identify their own names or identities. Every time a user requests to enter the system, the system will check and provide the right to use the system after passing the authentication.

  2) Access control: Through user authority definition and legal right check, ensure that only users with legal authority can access the database, and all unauthorized personnel cannot access the data. For example, discretionary access control (DAC) in class C2 and mandatory access control (MAC) in class B1;

  3) View mechanism: define views for different users, and hide the data to be kept secret from users who have no right to access through the view mechanism, thereby automatically providing a certain degree of security protection for data.

  4) Audit: Create an audit log to automatically record all operations of the user on the database and put them into the audit log. The DBA can use the audit trail information to reproduce a series of events that lead to the current status of the database and find out illegal access data who, when, and what.

  5) Data encryption: Encrypt the stored and transmitted data, so that people who do not know the decryption algorithm cannot know the content of the data.

  Please refer to 9.2 of "Introduction" for details.

    4. What are discretionary access control methods and mandatory access control methods in databases?

  Answer: Autonomous access control method: define the access rights of each user to different data objects. When the user accesses the database, first check the user's access authority. Prevent unauthorized users from accessing the database.

  Mandatory access control method: each data object is (mandatoryly) marked with a certain level of confidentiality, and each user is also (mandatoryly) granted a certain level of permission. The system stipulates that only users with a certain license level can access data objects of a certain confidentiality level.

  *Analysis: The meaning of autonomy in autonomous access control is: users can "autonomously" grant their own access rights to others. That is, the user has a certain "autonomous" right.

5. What data control (autonomous access control) statements are provided in the     SQL language? Give a few examples to illustrate how they are used.

  Answer: The autonomous access control in SQL is realized through the GRANT statement and the REVOKE statement. like:

  GRANT SELECT, INSERT ON Student TO 王平 WITH GRANT OPTION;

  The SELECT and INSERT permissions of the Student table are granted to user Wang Ping, and the subsequent "WITH GRANT OPTION" clause indicates that user Wang Ping has also obtained the "authorized" permission, that is, the obtained permissions can be continued to be granted to other users.

  REVOKE INSERT ON Student FROM Wang Ping CASCADE;

  The INSERT permission of the Student table is withdrawn from user Wang Ping, and the option CASCADE indicates that if user Wang Ping delegates the INSERT permission of Student to other users, then these permissions will also be withdrawn from other users.

  6. Now there are two relationship modes:

   Employee (employee number, name, age, position, salary, department number)

   Department (department number, name, manager name, address, phone number)

  Please use SQL GRANT and REVOKE statements (plus view mechanism) to complete the following authorization definition or access control functions:

   (a) User Wang Ming has the SELECT right to the two tables;

   GRANT SELECT ON employee, department TO Wang Ming;   

   (b) User Li Yong has INSERT and DELETE rights to the two tables;

   GRANT INSERT, DELETE ON employee, department TO Li Yong;

   (c) *Each employee has SELECT power only for his own records;

   GRANT SELECT ON 职工 WHEN USER()= NAME TO ALL;

  It is assumed here that the system's GRANT statement supports the use of the WHEN clause and USER(). Users will have their own name as ID. Note that these expansion statements may be different on different systems. Readers should be aware of the extended statements for the DBMS product you use.

   (d) User Liu Xing has the SELECT right to the employee table and the update right to the salary field;

   GRANT SELECT, UPDATE (salary) ON employee TO Liu Xing;

   (e) User Zhang Xin has the right to modify the structures of these two tables;

   GRANT ALTER TABLE ON employee, department TO Zhang Xin;

   (f) User Zhou Ping has all rights to the two tables (read, insert, modify, delete data), and has the right to authorize other users;

   GRANT ALL PRIVILIGES ON staff, department TO Zhou Ping WITH GRANT OPTION;

   (g) User Yang Lan has the power to SELECT the highest salary, the lowest salary, and the average salary from the employees of each department, but he cannot check everyone's salary.

  Answer: First create a view. Then define Yang Lan's access rights for this view.

   CREATE VIEW Department Salary AS

   SELECT department.name, MAX(salary), MIN(salary), AVG(salary)

   FROM employee, department

   WHERE employee.DepartmentNumber = department.DepartmentNumber

   GROUP BY employee. department number;

   GRANT SELECT ON department salary TO Yang Lan;

  7. For each of the cases (a)~(g) in Exercise 8 , revoke the power granted by each user.

  Answer: (a) REVOKE SELECT ON employee, department FROM Wang Ming;

    (b) REVOKE INSERT, DELETE ON staff, department FROM Li Yong;

    (c) REOVKE SELECT ON 职工 WHEN USER()= NAME FROM ALL;

  It is assumed here that the user uses his or her name as the ID, and the REOVKE statement of the system supports the WHEN clause, and the system also supports the use of USER().

  (d) REVOKE SELECT, UPDATE ON employee FROM Liu Xing;

  (e) REVOKE ALTER TABLE ON staff, department FROM Zhang Xin;

  (f) REVOKE ALL PRIVILIGES ON staff, department FROM Zhou Ping;

  (g) REVOKE SELECT ON department salary FROM Yang Lan;

  DROP VIEW department salary;

  8. Why does mandatory access control provide a higher level of database security?

  Answer: Mandatory Access Control (MAC) is to mark the data itself with a confidentiality level. No matter how the data is copied, the mark and the data are an inseparable whole. Only users who meet the requirements of the confidentiality mark can manipulate the data, thus providing a higher level. safety.

  9. Understand and explain the meanings of subjects, objects, and sensitivity marks in the MAC mechanism.

  Answer: The subject is an active entity in the system, including not only the actual user managed by the DBMS, but also the processes representing the user.

  The object is a passive entity in the system, which is manipulated by the subject, including files, base tables, indexes, views, etc.

  For subjects and objects, DBMS assigns a sensitivity mark (Label) to each instance (value) of them. Sensitivity marks are divided into several levels, such as Top Secret (Top Secret), Confidential (Secret), Credible (Confidential), Public (Public), etc. The sensitivity mark of the subject is called the clearance level (Clearance Level), and the sensitivity mark of the object is called the classification level (Classification Level).

  10. What is the audit function of the database, and why should it be provided?

  Answer: The audit function means that the audit module of the DBMS automatically records all operations into the system's audit log when the user performs operations on the database.

  Because the security protection measures of any system are not perfect, there is always the possibility of someone who willfully steal and destroy data. Using the audit function of the database, the DBA can reproduce a series of events that lead to the current status of the database based on the information of the audit trail, and find out who, when and what is illegally accessing the data.

  11. What special security issues exist in statistical databases?

  Answer: The statistical database allows users to query aggregated information, such as total, average, maximum value, minimum value, etc., but does not allow the query of single record information. However, people can deduce illegal information from legitimate queries, that is, there may be hidden information channels, which is a special security problem to be studied and solved by statistical databases.

   *12. Tell me about the security measures of an actual DBMS product you know .

Answer: Different DBMS products and different versions of the same product have different security measures. Different people have different opinions, and the wise have their own wisdom. Readers should understand it by themselves. 9.4 on "Introduction" briefly introduced the security measures of the ORACLE database.

5Database Integrity

  1. Multiple choice questions

  1.完整性检查和控制的防范对象( ),防止它们进入数据库。安全性控制的防范对象是( ),防止他们对数据库数据的存取。

  A. 不合语义的数据     B. 非法用户   C. 不正确的数据         D. 非法操作

  2.下述哪个是SQL语言中的数据控制命令( )。

  A. GRANT    B. COMMIT   C. UPDATE    D. SELECT

  3.下述SQL语言中的权限,哪一个允许用户定义新关系时,引用其他关系的主码作为外码( )。

  A. INSERT           B. DELETE   C. REFERENCES   D. SELECT

    参考答案:(1) A C B D (2) A (3) C

    二、简答题

  1.什么是数据库的完整性?

  答:数据库的完整性是指数据的正确性和相容性。

  2.数据库的完整性概念与数据库的安全性概念有什么区别和联系?

  答:数据的完整性和安全性是两个不同的概念,但是有一定的联系。

  前者是为了防止数据库中存在不符合语义的数据,防止错误信息的输入和输出,即所谓垃圾进垃圾出(Garbage In Garbage Out)所造成的无效操作和错误结果。

  后者是保护数据库防止恶意的破坏和非法的存取。

  也就是说,安全性措施的防范对象是非法用户和非法操作,完整性措施的防范对象是不合语义的数据。

  3.什么是数据库的完整性约束条件?可分为哪几类?

  答:完整性约束条件是指数据库中的数据应该满足的语义约束条件。

   Generally can be divided into six categories:

  Static column-level constraints, static tuple constraints, static relational constraints, dynamic column-level constraints, dynamic tuple constraints, dynamic relational constraints.

  A static column-level constraint is a description of the value range of a column, including the following aspects:

   1. Constraints on data types, including data type, length, unit, precision, etc.

   2. Constraints on data format

   3. Constraints on the value range or value set.

   4. Constraints on null values

   5. Other constraints

  The static tuple constraint is to specify the constraint relationship between the columns that make up a tuple, and the static tuple constraint is only limited to a single tuple.

  Static relational constraints are that there are often various connections or constraints between each tuple of a relation or among several relations. Common static relationship constraints are:

   1. Entity integrity constraints.

   2. Referential integrity constraints.

  3. Functional dependency constraints.

  Dynamic column-level constraints are constraints that should be met when modifying column definitions or column values, including the following two aspects:

   1. Constraints when modifying column definitions

   2. Constraints when modifying column values

  A dynamic tuple constraint means that when modifying the value of a tuple, its old value needs to be referred to, and certain constraints need to be satisfied between the old and new values.

  Dynamic relationship constraints are restrictions imposed on the state before and after the relationship changes, such as transaction consistency, atomicity and other constraints.

  For details, please refer to the introduction in "Introduction" 10.1.

  4. What functions should the integrity control mechanism of DBMS have?

  Answer: The integrity control mechanism of DBMS should have three functions:

  1). Definition function, which provides a mechanism for defining integrity constraints.

   2. Checking function, that is, checking whether the operation request sent by the user violates the integrity constraints.

  3). Breach response: If it is found that the user's operation request makes the data violate the integrity constraints, take certain actions to ensure the integrity of the data.

  5. What aspects does an RDBMS need to consider when implementing referential integrity?

  Answer: RDBMS needs to consider the following aspects when implementing referential integrity:

   1) Whether the outer key can accept null value

   2) Considerations when deleting the tuple of the referenced relationship. At this time, the system may adopt three methods:

   (a) cascading deletes (CASCADES);

   (b) RESTRICTED;

   (c) Null value deletion (NULLIFIES)

   3) When inserting a tuple in the reference relationship, the system may adopt the following methods:

   (a) Restricted Insertion

   (b) Recursive insertion

   4) Modify the problem of the primary key in the relationship

  Generally, the UPDATE statement cannot be used to modify the relational primary key. If you need to modify the primary key value, you can only delete the tuple first, and then insert the tuple with the new primary key value into the relation.

  If the master key is allowed to be modified, the uniqueness and non-nullness of the master key must first be guaranteed, otherwise the modification is refused. Then it is necessary to distinguish whether it is a reference relationship or a reference relationship.

  A detailed discussion can be found in Introduction 10.2.

  6. Assume that there are the following two relational schemas:

   Employee (employee number, name, age, position, salary, department number), where the employee number is the main code;

   Department (department number, name, manager name, phone number), where the department number is the main code;

  Defining these two relational schemas in SQL language requires the definition of the following integrity constraints in the schema:

  Define the main code of each mode; define referential integrity; define the age of employees must not exceed 60 years old.

  答:CREATE TABLE DEPT

   (Deptno NUMBER(2),

   Deptname VARCHAR(10),

   Manager VARCHAR(10),

   PhoneNumber Char(12)

   CONSTRAINT PK_SC PRIMARY KEY (Deptno));

   CREATE TABLE EMP

   (Empno NUMBER(4),

   Ename VARCHAR(10),

   Age NUMBER(2),

   CONSTRAINT C1 CHECK (Age《=60),

   Job VARCHAR(9),

   Sal NUMBER(7,2),

   Deptno NUMBER(2),

   CONSTRAINT FK_DEPTNO

   FOREIGN KEY (Deptno)

   REFERENCES DEPT(Deptno));

  7 . In relational systems, when operations violate entity integrity, referential integrity, and user-defined integrity constraints, how are they generally handled separately?

  Answer: Operations that violate entity integrity and user-defined integrity are generally handled by denying execution. However, operations that violate referential integrity are not always simply refused to execute, and sometimes some additional operations must be performed according to the application semantics to ensure the correctness of the database. For specific treatment, please refer to Question 5 above or the corresponding part in "Introduction" 10.2.

  *8. Describe the integrity control strategy of an actual DBMS product that you know.

  Answer: Different DBMS products and different versions of the same product have different integrity control strategies. Readers need to understand the integrity control strategy of a certain DBMS product.

Chapter 6 Relational Data Theory

  1. Multiple choice questions

  1. In order to design a relationship model with better performance, it must be standardized, and the main theoretical basis for normalization is ( ) .

  A. Relational Normalization Theory B. Relational Algebra Theory C. Mathematical logic D. Relational operation theory

  2. Normalization theory is the theoretical basis for the logical design of relational databases. According to this theory, the relationship in relational databases must satisfy: each attribute is ( ) .

  A. Invariant in length B. Indecomposable C. interrelated D. unrelated

  3. Known relational pattern R (A , B , C , D , E ) and its functional correlation set F = {A →D , B →C , E →A} , the candidate keywords of this relational pattern are ( ) .

  A.AB     B. BE   C.CD D. DE

  4. Let the primary key of the student relationship S (SNO , SNAME , SSEX , SAGE , SDPART ) be SNO, and the primary key of the student course selection relationship SC (SNO , CNO , SCORE ) be SNO and CNO , then the relationship R (SNO , CNO , SSEX , SAGE , SDPART , SCORE ) whose primary keys are SNO and CNO , which satisfy ( ).

  A. 1NF   B.2NF    C. 3NF    D. BCNF

  5. There is a relationship model W (C , P , S , G , T , R ), where the meaning of each attribute is: C means course, P means teacher, S means student, G means grade, T means time, R means Classroom, according to the semantics, there are the following data dependency sets: D={ C → P , (S , C ) → G , (T , R ) → C , (T , P ) → R , (T , S ) → R } , A keyword of the relation schema W is ( ) .

  A. (S,C) B. (T,R)  C. (T,P) D. (T,S)

  6. Among the relational patterns, the pattern ( ) that satisfies 2NF .

A. May be 1NF B. Must be 1NF C. Must be 3NF D. Must be BCNF

  7. The attributes in the relational schema R are all primary attributes, then the highest normal form of R must be ( ) .

  A. 1NF   B. 2NF   C. 3NF     D. BCNF

  8. The 1NF relationship pattern that eliminates some functional dependencies must be ( ) .

  A. 1NF   B. 2NF   C. 3NF     D. BCNF

  9. If A -> B, then the connection between attribute A and attribute B is ( ) .

  A. One to many B. Many to one C. Many to many D. None of the above

  10. There can be one or more candidate keywords in the relationship mode , and there are ( ) for the main keyword .

  A. Multiple B. 0 C. 1 D. 1 or more

  11. The attributes of candidate keywords can have ( ) .

  A. Multiple B. 0 C. 1 D. 1 or more

  12. Any attribute of the relation schema ( ) .

  A. Cannot be subdivided B. Can be subdivided C. The naming can not be unique in the relationship mode D. None of the above

  13. There is a relationship model W (C , P , S , G , T , R ), where the meaning of each attribute is: C means course, P means teacher, S means student, G means grade, T means time, R means Classroom, according to the semantics, there are the following data dependency sets: D={ C → P , (S , C ) → G , (T , R ) → C , (T , P ) → R , (T , S ) → R } , If the relational schema W is decomposed into three relational schemas W1 (C , P ), W2 (S , C , G ), W2 (S , T , R , C ), the normalization procedure of W1 can reach ( ) .

  A. 1NF   B.2NF      C. 3NF   D. BCNF

  14. In a relational database, the highest normal form of any binary relational schema must be ( ) .

  A. 1NF   B.2NF   C. 3NF      D. BCNF

  15. In the relationship specification formula, the basic principle of decomposing the relationship is ( ).

  I. Achieve lossless connection

  II. The decomposed relationships are independent of each other

  III. Keep the original dependencies

  A. Ⅰ and Ⅱ B. Ⅰ and Ⅲ C. Ⅰ D. Ⅱ

  16. The condition that cannot transform a relationship from the first normal form to the second normal form is ( ).

  A. Every non-property is fully functionally dependent on the main property B. Every non-property is partially functionally dependent on the main property

  C. No non-attribute exists in a relation D. The primary key consists of an attribute

  17. Any relation pattern that satisfies 2NF but not 3NF does not exist ( ).

  A. Partial dependence of primary attributes on keys B. Partial dependence of non-primary attributes on keys

  C. Transitive dependency of primary attributes on keys D. Transitive dependency of non-primary attributes on keys

  18. Suppose the database relational schema R = (A , B , C , D , E ), has the following functional dependencies: A → BC , D → E , C → D ; among the following decompositions of R, which decompositions are R Lossless join factorization( ) .

  I.(A,B,C)(C,D,E)

  II.(A,B)(A,C,D,E)

  III.(A,C)(B,C,D,E)

  IV. (A, B) (C, D, E)

  A. Only IV B. I and II C. I, II and III D. None

  19. Let U be the set of all attributes, X , Y , Z are all subsets of U, and Z = U - X - Y . In the following statement about multi-valued dependencies, the incorrect one is ( ).

A. If X→→Y, then X→→Z B. If X→Y, then X→→Y

C. If X→→Y, and Y′∈Y, then X→→Y′ D. If Z=∮, then X→→Y

  20. If the relation pattern R (U , F ) belongs to 3NF , then ( ).

  A. Must belong to BCNF B. Eliminates insertion and deletion anomalies

  C. There are still some insertion and deletion anomalies D. It belongs to BCNF and the insertion and deletion anomalies are eliminated

  21. Which of the following statements is incorrect ( ).

  A. Any relational schema containing two attributes must satisfy 3NF

       B. Any relational schema containing two attributes must satisfy BCNF

  C. Any relational schema containing three attributes must satisfy 3NF D. Any relational schema must have a code

  22. Suppose the relation pattern R (A , B , C ), F is the FD set established on R , F = {B → C} , then decompose P = {AB , BC} relative to F ( ).

  A. It is a lossless connection, and it also maintains the decomposition of FD. B. It is a lossless connection, and it does not maintain the decomposition of FD.

  C. is not a lossless join, but preserves the decomposition of FD D. is neither a lossless join nor preserves the decomposition of FD

  23. Relational database normalization is introduced to solve the problems in ( ) in relational databases.

  A. Insertion, deletion, and data redundancy B. Increased query speed

  C. Reduce the complexity of data operations D. Ensure data security and integrity

  24. In the standardization of relations, the relation between each paradigm is ( ) .

  A. 1NF∈2NF∈3NF   B. 3NF∈2NF∈1NF   C. 1NF=2NF=3NF   D. 1NF∈2NF∈BCNF∈3NF

  25. The redundant data in the database refers to the data that can be ( ) .

  A. Prone to errors B. Prone to conflicts C. Irrelevant D. Derived from basic data

  26. Student table (id , name , sex , age , depart_id , depart_name ), there is a functional dependency is id → name , sex , age , depart_id ; dept_id → dept_name , which satisfies ( ).

  A. 1NF         B. 2NF     C. 3NF          D. BCNF

  27. Assuming a relational pattern R (S , D , M ) and a set of functional dependencies: F = {S → D , D → M} , then the standardization degree of the relational pattern R reaches ( ).

  A. 1NF         B. 2NF     C. 3NF          D. BCNF

28. If there is a relational schema R (A , B , C , D ), and its data dependency set: F = { (A , B )→C , C →D} , the normalization degree of the relational schema R can reach ( ).

  A. 1NF         B. 2NF     C. 3NF          D. BCNF

  29. Which of the following statements about functional dependencies is incorrect ( ).

  A. From X→Y, Y→Z, then X→YZ B. From X→YZ, then X→Y, Y→Z

  C. From X→Y, WY→Z, then XW→Z D. From X→Y, Z∈Y, then X→Z

  30. X → Y , when which of the following is true, it is called trivial functional dependence ( ).

  A. X∈Y        B. Y∈X   C. X∩Y=∮       D. X∩Y≠∮

  31. The normalization theory of relational databases points out that the relations in relational databases should meet certain requirements, and the minimum requirement is to reach 1NF , that is, to meet ( ).

  A. Every non-primary key attribute is completely dependent on the primary key attribute B. The primary key attribute uniquely identifies the tuple in the relation

  C. The tuples in the relation are not repeatable D. Each attribute is not decomposable

  32. According to the normalization theory of relational database, the relationship in relational database must satisfy the first normal form. In the department (department number, department name, department member, department general manager) relationship, which attribute makes it not satisfy the first normal form ( ) .

  A. Department General Manager B. Department Members C. Department Name D. Department Number

  33. There is a relationship schema A (C , T , H , R , S ), where the meaning of each attribute is: C : course T : teacher H : class time R : classroom S : student. According to the semantics, there are the following functional dependency sets: F={C → T , (H , R ) → C , (H , T ) RC , (H , S ) → R}

  (1) The code of relation schema A is ( ).

          A. C              B.(H,S) C.(H,R) D.(H,T)

  (2) The normalization degree of relational schema A reaches ( ).

         A. 1NF          B. 2NF           C. 3NF          D. BCNF

  (3) Now decompose the relational schema A into two relational schemas A1 (C, T) and A2 (H, R, S), and the standardization degree of A1 reaches ( ).

  A. 1NF         B. 2NF     C. 3NF          D. BCNF

  参考答案: (1) A (2) B (3) B (4) A (5) D (6) B (7) C (8) B (9) B (10) C (11) D (12) A (13) D (14) D (15) B(16) B (17) D (18) B (19) C (20) C (21) C (22) A (23) A (24) A (25) D (26) B (27) B (28) B (29) B (30) B (31) D (32) B (33) B B D

  二、简答题

  1.理解并给出下列术语的定义:

  函数依赖、部分函数依赖、完全函数依赖、候选码、主码、 外码、全码。

  解析:解答本题不能仅仅把《概论》上的定义写下来。关键是真正理解和运用这些概念。

  答: 函数依赖:设R (U)是一个关系模式,U是R的属性集合,X和Y是U的子集。对于R (U)的任意一个可能的关系r,如果r中不存在两个元组,它们在X上的属性值相同, 而在Y上的属性值不同, 则称"X函数确定Y"或"Y函数依赖于X",记作X→Y。

  解析:1)函数依赖是最基本的一种数据依赖,也是最重要的一种数据依赖。

  2)函数依赖是属性之间的一种联系,体现在属性值是否相等。由上面的定义可以知道,如果X→Y,则r中任意两个元组,若它们在X上的属性值相同,那么在Y上的属性值一定也相同。

  3)我们要从属性间实际存在的语义来确定他们之间的函数依赖,即函数依赖反映了(描述了)现实世界的一种语义。

  4)函数依赖不是指关系模式R的在某个时刻的关系(值)满足的约束条件,而是指R任何时刻的一切关系均要满足的约束条件。

  答: 完全函数依赖、部分函数依赖:在R(U)中,如果X→Y,并且对于X的任何一个真子集X,都有X′→Y,则称Y对X完全函数依赖;若X→Y,但Y不完全函数依赖于X,则称Y对X部分函数依赖;

  Candidate key, primary key: Let K be an attribute or a combination of attributes in R(U, F), if K → U, then K is a candidate key of R. If there are more than one candidate key, one of them is selected as the main key.

  Answer: Outer key: The attribute or attribute group X in the relational schema R is not the key of R, but X is the key of another relational schema, then X is said to be the outer key of R, also known as the outer key.

  All-key: The entire attribute group is a key, called All-key.

  2 . Build a relational database of information about departments, students, classes, societies, etc.

  The attributes describing students include: student number, name, date of birth, department name, class number, and dormitory area.

  The attributes describing a class include: class number, major name, department name, number of people, and year of admission.

  The attributes describing a department include: department name, department number, department office location, and number of people.

  The attributes describing the society include: society name, year of establishment, location, and number of people.

  The relevant semantics are as follows: a department has several majors, each major only recruits one class each year, and each class has a number of students. Students of one department live in the same dormitory area. Each student can participate in several societies, and each society has several students. There is one year of membership for a student to join an academy.

  Please give the relational schema, write down the minimal set of functional dependencies of each relational schema, point out whether there is a transitive functional dependency, and discuss whether the functional dependency is a complete functional dependency or a partial functional dependency when the left part of the functional dependency is multi-attribute.

  Point out the candidate codes and external codes of each relationship. Is there a full code?

  Answer: Relational schema: Student S (S#, SN, SB, DN, C#, SA)

   Class C (C#, CS, DN, CNUM, CDATE)

   系 D(D#,DN,DA,DNUM)

   Learn P (PN, DATE1, PA, PNUM)

   Student -- Learn SP (S#, PN, DATE2)

  Among them, S#—student number, SN—name, SB—date of birth, SA—dormitory area

   C#—class number, CS—professional name, CNUM—class number, CDATE—enrollment year

   D#—department number, DN—department name, DA—department office location, DNUM—department number

   PN—the name of the society, DATE1—the year and month of establishment, PA—the location, PNUM—the number of people in the society, DATE2—the year of membership

  Minimal set of functional dependencies for each relational schema:

   S:S#→SN,S#→SB,S#→C#,C#→DN,DN→SA

   C:C#→CS,C#→CNUM,C#→CDATE,CS→DN,(CS,CDATE)→C#

   D:D#→DN,DN→D#,D#→DA,D#→DNUM

   P:PN→DATE1,PN→PA,PN→PNUM

   SP:(S#,PN)→DATE2

  There is a transfer function dependency in S: S#→DN, S#→SA, C#→SA

  There is a transitive functional dependency in C: C#→DN

  (S#, PN) → DATE2 and (CS, CDATE) → C# are both functional dependencies in SP, which are complete functional dependencies

  Relation Candidate Code External Code Full Code

  SS# C#, DN None

  CC#, (CS,CDATE) DN None

  DD# and DN None None

  P PN None None

  SP (S#, PN) S#, PN None

  3. Try to derive the following three inference rules from the Armostrong axiom system:

  (1) Merge rule: if X→Z, X→Y, then X→YZ

  (2) Pseudo-transitive rules: X→Y, WY→Z has XW→Z

  (3) Decomposition rules: X→Y, Z is included in Y, X→Z

  Proof: (1) Given X→Z, XY→YZ is known by the augmented law, and because of X→Y, XX→XY→YZ can be obtained, and finally X→YZ can be obtained according to the transitive law.

  (2) Given X→Y, XW→WY can be obtained according to the augmented law, because WY→Z, so XW→WY→Z, and XW→Z can be known through the transitive law.

  (3) It is known that Z is included in Y, and Y→Z is known according to the reflexive law, and because X→Y, X→Z can be obtained by the transitive law.

  4. Which of the following conclusions are correct and which are wrong? For wrong conclusions, please give reasons or give a counterexample to illustrate it.

  (1) Any binary relationship belongs to 3NF.

  (2) Any binary relation belongs to BCNF.

  (3) Any binary relationship belongs to 4NF.

  (5) If RA→RB, RB→RC, then RA→RC √

  (6) If RA→RB, RA→RC, then RA→R.(B, C) √

  (7) If RB→RA, RC→RA, then R.(B, C)→RA √

  (8) If R.(B, C)→RA, then RB→RA, RC→RA ×

Counterexample: relational schema SC(S#, C#, G) (S#, C#) → G, but S# → G, C# → G

7 Database Design

  1. Multiple choice questions

  1. A data flow diagram is a tool used to describe the ( ) stages in a structured approach .

  A. Outline Design B. Feasibility Analysis C. Program Coding D. Requirements Analysis

  2. In database design, use E -R map to describe the information structure but does not involve the representation of information in the computer, which is the database design ( ).

  A. Requirements Analysis Phase B. Logical Design Phase C. Conceptual Design Phase D. Physical Design Phase

  3. In database design, the process of converting ER diagrams into relational data models belongs to ( ).

  A. Requirements Analysis Phase B. Logical Design Phase C. Conceptual Design Phase D. Physical Design Phase

  4. Sub-mode DDL is used to describe ( ).

  A. The overall logical structure of the database B. The partial logical structure of the database

  C. The physical storage structure of the database D. The conceptual structure of the database

  5. In the conceptual design stage of database design, the common methods and description tools for expressing conceptual structure are ( ).

  A. Analytic Hierarchy Process and Hierarchy Diagram B. Data Process Analysis and Data Flow Chart

  C. Entity connection method and entity connection diagram D. Structural analysis method and module structure diagram

  6. When the E -R model is transformed into a relational model, when the connection of M :N is transformed into a relational model, its keyword is ( ).

  The keywords of the AM-side entity, the keyword CM of the BN-side entity, and the keyword combination of the N-side entity D. Reselect other attributes

  7. A school stipulates that each class has a maximum of 50 students and at least 10 students; each student must belong to a class. In the relationship between the class and the student entity, the cardinality of the student entity is ( ) .

  A. (0,1)        B. (1,1)   C. (1,10)       D. (10,50)

  8. In relational database design, designing relational schema is a task in the ( ) phase of database design .

  A. Logical Design Phase B. Conceptual Design Phase C. Physical Design Phase D. Requirements Analysis Phase

  9. The main problem solved by the normalization theory of relational database is ( ).

  A. How to construct a suitable data logical structure B. How to construct a suitable data physical structure

  C. How to construct a suitable application program interface D. How to control the data operation permissions of different users

  10. Database design can be divided into seven stages, each stage has its own design content, the design content of "for which relationship, on which attribute, and key key" should belong to the ( ) design stage .

  A. Conceptual Design B. Logical Design C. Physical Design D. Global Design

  11. Assuming that the design database performance is measured by "overhead", that is, time, space and possible costs, there are many overheads in the lifetime of the database application system. Among them, for physical designers, the main consideration is ( ).

  A. Planning overhead B. Design overhead C. Operational overhead D. Maintenance overhead

  12. After the physical design of the database is completed, it enters the database implementation stage. Among the following tasks, ( ) generally do not belong to the implementation stage.

  A. Building library structure B. System debugging C. Loading data D. Expanding functions

  13. When exporting the relationship model from the ER diagram, if the connection between entities is M :N , which of the following statements is correct ( ).

  A. Incorporate the keywords and attributes of the N party into the attributes of the M party B. Incorporate the keywords and attributes of the M party into the attributes of the N party

  C. Add a relationship to indicate the connection, which includes the keywords of M and N parties

  D. Add an attribute indicating the level to both the M-side attribute and the N-side attribute

  14. In the ER model, if there are 3 different entity sets and 3 M :N connections, according to the rules for converting the ER model to a relational model, the number of relationships converted to is ( ).

  A. 4       B. 5   C. 6       D. 7 

  Reference answer:   (1) D (2) C (3) B (4) B (5) C (6) C (7) B (8) A (9) A (10) C (11) C (12) D (13) C (14) C

  2. Short answer questions

  1. Describe the database design process.

  *Analysis: I hope that students can read the content of "Introduction" carefully to understand and master the database design process. Here is just an overview of the six phases of the database design process:

  1) Demand analysis

  2) Conceptual structure design

  3) Logic structure design

  4) Database physical design

  5) Database implementation

  6) Database operation and maintenance

  This is a complete design process of the actual database and its application system. Including not only the design of the database itself, but also the implementation, operation and maintenance of the database.

  Designing a complete database application system is often a constant repetition of the above six stages.

  2. Try to describe the design description at each stage of the database design process.

  *Analysis: This is to further understand the specific content of database design. Design description refers to various documents and programs that embody design content and describe design results at each stage.

  Answer: The design points of each stage are as follows:

  1) Demand analysis: Accurately understand and analyze user needs (including data and processing).

  2) Conceptual structure design: Through the synthesis, induction and abstraction of user requirements, a conceptual model independent of the specific DBMS is formed.

  3) Logical structure design: convert the conceptual structure into a data model supported by a certain DBMS, and optimize it.

  4) Database physical design: select a physical structure (including storage structure and access method) that is most suitable for the application environment for the logical data model.

  5) Database implementation: Designers use the data language, tools and host language provided by DBMS to build databases according to the results of logical design and physical design, compile and debug application programs, organize data storage, and conduct trial operations.

  6) Database operation and maintenance: evaluate, adjust and modify the database system during its operation.

  3. Try to describe the database schema formed in the structural design part of the database design process.

  Answer: The different stages of database structure design form the various levels of schema of the database, namely:

  In the conceptual design stage, a conceptual model that is independent of the characteristics of the machine and of each DBMS product is formed, which is the ER diagram in this article;

  In the logical design stage, the ER diagram is converted into a data model supported by specific database products, such as a relational model, to form a database logic model; then, on the basis of the basic table, necessary views (View) are established to form an external model of data;

  In the physical design stage, according to the characteristics of DBMS and the needs of processing, physical storage arrangements are made, indexes are established, and schemas in the database are formed.

  The conceptual model is oriented to users and designers, and belongs to the level of the conceptual model; the logical model, external model, and internal model are the modes supported by the DBMS, and belong to the level of the data model. Can be described and stored in a DBMS.

  4. Describe the characteristics of database design.

  Answer: Database design is both a comprehensive technology involving multiple disciplines and a huge engineering project. Its main features are:

  1) Database construction is a combination of hardware, software and dryware (interface between technology and management).

  2) From the technical point of view of software design, database design should be combined with application system design, that is to say, structure (data) design and behavior (processing) design should be closely combined in the whole design process.

  5. What is the design goal of the requirements analysis phase? What is the content of the investigation?

  Answer: The design goal of the requirements analysis stage is to fully understand the working situation of the original system (manual system or computer system) through detailed investigation of the objects to be dealt with in the real world (organizations, departments, enterprises, etc.), to clarify the various needs of users, and then to Based on this, the functionality of the new system is determined.

  The content of the survey is "data" and "processing", that is, to obtain the following requirements of the user for the database:

  (1) Information requirements. Refers to the content and nature of the information that users need to obtain from the database. Data requirements can be derived from the information requirements, ie which data needs to be stored in the database.

  (2) Processing requirements. Refers to what processing function the user wants to complete, what requirements are there for the processing response time, and whether the processing method is batch processing or online processing.

  (3) Security and integrity requirements. 

  6. What is the content and function of the data dictionary?

  Answer: The data dictionary is a collection of various data descriptions in the system. The content of the data dictionary usually includes five parts: data items, data structure, data flow, data storage, and processing

  Among them, a data item is the smallest unit of data, and several data items can form a data structure. The data dictionary describes the logical content of data flow and data storage through the definition of data items and data structures.

  The role of the data dictionary:

  The data dictionary is a description of the data in the database. It is established in the requirement analysis stage and is the basis for the next conceptual design. It is constantly modified, enriched, and perfected during the database design process.

  (Note that the data dictionary formed during the database design phase is different from the data dictionary mentioned later. The latter is the description of the data in the database by the DBMS. Of course, the two are related).

  7. What is the conceptual structure of a database? Describe its characteristics and design strategies.

  Answer: The conceptual structure is the structure of the information world, that is, the conceptual model. Its main characteristics are:

  (1) It can truly and fully reflect the real world, including the relationship between things and things, and can meet the user's data processing requirements. is a realistic model of the real world.

  (2) It is easy to understand, so that it can be used to exchange ideas with users who are not familiar with computers. The active participation of users is the key to the success of database design.

  (3) It is easy to change. When the application environment and application requirements change, it is easy to modify and expand the conceptual model.

  (4) It is easy to convert to various data models such as relational, network, and hierarchical.

  There are generally four design strategies for conceptual structures:

  · top down. That is, first define the framework of the global conceptual structure, and then gradually refine it;

  · Bottom up. That is, first define the conceptual structure of each local application, and then integrate them to obtain the global concept

  structure;

  · Gradual expansion. First define the most important core concept structure, and then expand outward to gradually generate

  into other conceptual structures up to the overall conceptual structure;

  • Mixed strategies. It is about combining top-down and bottom-up, using top-down strategy to design a global conceptual structure

  Framework, which is used as the skeleton to integrate the partial conceptual structures designed in the bottom-up strategy.

  8. What is data abstraction? Try an example.

  Answer: Data abstraction is the artificial processing of actual people, things, things and concepts, extracting the common characteristics of concern, ignoring non-essential details, and accurately describing these characteristics with various concepts. These concepts constitute a certain kind of model.

  如分类这种抽象是:定义某一类概念作为现实世界中一组对象的类型。这些对象具有某些共同的特性和行为。它抽象了对象值和型之间的“is member of”的语义。在E-R模型中,实体型就是这种抽象。例如在学校环境中,李英是老师,表示李英是教师类型中的一员,则教师是实体型,李英是教师实体型中的一个实体值,具有教师共同的特性和行为:在某个系某个专业教学,讲授某些课程,从事某个方向的科研。 

  9.试述数据库概念结构设计的重要性和设计步骤。

  答: 重要性:

  数据库概念设计是整个数据库设计的关键,将在需求分析阶段所得到的应用需求首先抽

  象为概念结构,以此作为各种数据模型的共同基础,从而能更好地、更准确地用某一DBMS实现这些需求。

  设计步骤:

  概念结构的设计方法有多种,其中最经常采用的策略是自底向上方法,该方法的设计步

  骤通常分为两步:第1步是抽象数据并设计局部视图,第2步是集成局部视图,得到全局的概念结构

  10.什么是E-R图?构成E-R图的基本要素是什么?

  答: E-R图为实体-联系图,提供了表示实体型、属性和联系的方法,用来描述现实世界的概念模型。

  构成E-R图的基本要素是实体型、属性和联系,其表示方法为:

  · 实体型:用矩形表示,矩形框内写明实体名;

  · 属性:用椭圆形表示,并用无向边将其与相应的实体连接起来;

  · 联系:用菱形表示,菱形框内写明联系名,并用无向边分别与有关实体连接起来,同时在无向边旁标上联系的类型(1 : 1,1 : n或m : n)。 

  11. 为什么要视图集成?视图集成的方法是什么?

  Answer: When designing the conceptual structure of the database system, the bottom-up design method is generally used to decompose the complicated large system into subsystems. Firstly, the partial view of each subsystem is designed, and then the subsystems are organically integrated through the view integration method to synthesize a general view of the system. This design is clear, from simple to complex. Since the database system views and describes data from an overall perspective, the data is no longer oriented to a certain application but to the entire system. Therefore, view integration must be carried out so that the database can be shared and used by multiple users and multiple applications in the whole system.

  Generally speaking, view integration can be done in two ways:

  · One-time integration of multiple sub-ER diagrams;

  · Integrate gradually, and integrate two sub-ER diagrams at a time in an accumulative manner.

  No matter which method is used, two steps are required to integrate the partial ER diagram each time:

  (1) Merge. Solve the conflicts between the sub-ER diagrams, and merge the sub-ER diagrams to generate a preliminary ER diagram.

  (2) Modification and reconstruction. Eliminate unnecessary redundancy and generate basic ER diagrams.

   12. What is the logical structure design of the database? Describe its design steps.

  Answer: The logical structure design of the database is to transform the basic ER diagram designed in the conceptual structure design stage into a logical structure consistent with the data model supported by the selected DBMS product.

  The design steps are:

  (1) Transform conceptual structures into general relational, network, and hierarchical models;

  (2) Convert the converted relational, network, and hierarchical models to data models supported by a specific DBMS;

  (3) Optimize the data model.   

  13. Describe the conversion rules for converting ER diagrams into DBTG models and relational models.

  Answer: Conversion rules from ER diagram to DBTG model:

  1) Each entity type is converted into a record type, and the attributes of the entity are converted into recorded data items;

  2) The 1:n (n≥1) connection between entity types is converted into a system, and the entity type without any connection is converted into a singular system;

  3) For the many-to-many relationship between K (K≥2) entity types, a link record is introduced to form K relationships between K entity types and link records. The attributes of the linked records are composed of the codes of the first records and the linked attributes;

  4) For the 1:n, n:m relationship in the same entity type, import the connection record and convert it into two systems.

  *Analysis: According to the reality of our country, network and hierarchical database systems are rarely used, so they are deleted in the third edition of "Introduction", and the relevant main concepts are introduced in the first chapter of the data model. Many concepts of the DBTG model are also introduced very simply. The content of this question has exceeded the content in the book, and students only need to understand it. However, the following conversion rules from ER diagram to relational model require students to master and be able to infer other cases from one instance.

  Answer: Conversion rules from ER diagram to relational model:

  An entity type is converted to a relational schema. The attribute of the entity is the attribute of the relationship, and the code of the entity is the code of the relationship.

  For the relationship between entities, there are the following different situations:

  (1) A 1:1 relationship can be converted into an independent relational schema, and can also be merged with the corresponding relational schema at either end. If it is transformed into an independent relation mode, the codes of the entities connected to the relation and the attributes of the relation itself are transformed into the attributes of the relation, and the codes of each entity are candidate codes of the relation. If it is merged with the relational schema corresponding to a certain end entity, it is necessary to add the code of another relational schema and the attribute of the relationship itself to the attribute of the relational schema.

  (2) A 1:n relationship can be converted into an independent relational schema, or merged with the corresponding relational schema at the n-terminal. If it is transformed into an independent relation mode, the codes of the entities connected to the relation and the attributes of the relation itself are transformed into the attributes of the relation, and the code of the relation is the code of the n-terminal entity.

  (3) An m:n relationship is transformed into a relational schema. The codes of each entity connected to the relationship and the attributes of the relationship itself are converted into attributes of the relationship, and the combination of the codes of each entity constitutes the code of the relationship, or a part of the code.

  (4) A multiple connection between three or more entities can be converted into a relational model. The codes of each entity connected to the multiple relationship and the attributes of the relationship itself are converted into attributes of the relationship, and the code of the relationship is the combination of the codes of each entity.

  (5) Relational schemas with the same code can be merged.

  *14. Can you give the conversion rules from ER diagram to IMS model?

  Answer: Conversion rules from ER diagram to IMS model:

  1) Each entity type is converted into a record type, and the attributes of the entity are converted into recorded data items;

  2) 1:n (n≥1) connection between entity types converts directed edges between record types;

  3)实体型之间m:n(m>1,n>1)的联系则分解成一对多联系,再根据2)转换;

  4)K(K≥2)个实体型之间多对多的联系,可先转换成多对两个实体型之间的联系,再根据3)转换。

*解析:IMS是IBM公司的层次数据库管理系统。IMS模型是层次模型。E-R图向IMS模型转换的另一种方法是,先把E-R图转换为网状模型,再利用IMS逻辑数据库LDB的概念来表示网状模型。详细方法这里从略。

                                             

                                            题库二

数据库系统原理练习题第1章

一、选择题

  1. 数据库(DB)、数据库系统(DBS)和数据库管理系统(DBMS)之间的关系是( )。

A. DBS包括DB和DBMS              B. DBMS包括DB和DBS

C. DB包括DBS和DBMS              D. DBS就是DB,也就是DBMS

  1. 概念模型是现实世界的第一层抽象,这一类模型中最著名的模型是( )。
  1. 层次模型       B. 关系模型       C. 网状模型        D. 实体-联系模型
  1. 目前,数据库管理系统最常用的逻辑数据模型是( )。

A.网状模型                   B.层次模型

C.关系模型                   D.面向对象模型

  1. 下列四项中,不属于数据库系统特点的是( )。
  1. 数据共享     B. 数据完整性    C. 数据冗余度高   D. 数据独立性高
  1. 数据模型的三个要素分别是( )。
    1. 实体完整性、参照完整性、用户自定义完整性
    2. 数据结构、数据操作、数据完整性约束条件 
    3. 插入数据、修改数据、删除数据
    4. 外模式、模式、内模式 
  2. 数据库三级结构从内到外的3个层次依次为()。
  1. 外模式、模式、内模式            B. 内模式、模式、外模式

C. 模式、外模式、内模式             D. 内模式、外模式、模式

  1. 下列关于数据库系统的正确叙述是():
    1. 数据库系统减少了数据冗余
    2. The database system avoids all redundancy
    3. The consistency of data in a database system refers to the consistency of data types
    4. Database systems can manage more data than file systems
  2. The logical independence of the data refers to ( ).

A.Keep the application unchanged when the external mode changes B. Keep the outer mode unchanged when the mode changes

C.Keep the schema unchanged when the internal schema changes D. Keep application unchanged when data changes

  1. The physical independence of data refers to ( ).

A.Keep the application unchanged when the external mode changes B. Keep the outer mode unchanged when the mode changes

C.Keep the schema unchanged when the internal schema changes D. Keep application unchanged when data changes

  1. The company has multiple departments and multiple employees. Each employee can only belong to one department. A department can have multiple employees. The connection type from department to employee is ().
    1. many to many B. one to one C. many to one D. one to many
  2. Savings have multiple depositors, depositors deposit between multiple savings banks, and the depositors and savings banks are ().
    1. One-to-one relationship B. One-to-many relationship C. Many-to-many relationship D. Uncertain relationship
  3. It is ( ) that describes the global logical structure and characteristics of all data in the database.
    1. Mode B. Inner mode C. Outer mode D. Above three levels of mode

Two, fill in the blank

  1. A database system generally consists of ( ), ( ), ( ) and ( ).
  2. A database is a collection of ( ) and ( ) data stored in a computer for a long time.
  3. DBMS means ( ), which is a layer of data management software located between ( ) and ( ).
  4. The connection between entities can be abstracted into three categories, which are ( ), ( ) and ( ).
  5. The three elements of the data model include three parts ( ), ( ) and ( ).
  6. According to the different application purposes of the data model, the data model is divided into ( ), ( ) and ( ).
  7. Named according to the type of data structure, the logical model is divided into ( ), ( ) and ( ), etc.
  8. In the ER diagram, ( ) represents an entity, ( ) represents an attribute, and ( ) represents a relationship between entities.

3. Brief description

  1. What is the definition of database?
  2. What are the main functions of a database management system?
  3. What are the three elements of a data model?
  4. What are the data operations in the database?
  5. What are the three types of connections between entity types?
  6. What are the logical data models commonly used in the database field?
  7. What parts does a database system consist of?
  8. Database system three-level schema structure?

Principles of Database System Exercises Chapter 2

1. Multiple choice questions

  1. Regarding the relational model, which of the following statements is incorrect ( ).
  1. The relational model is built on the basis of set algebra      
  2. The logical structure of the data is a two-dimensional table      
  3. Relational operations are set-oriented operations       
  4. The data in the relation can be arbitrary
  1. Regarding relationships, which of the following statements is incorrect ( ).
    1. Each attribute value in the relationship is indecomposable B. The same tuple is not allowed in the relationship 

C. The order between tuples is not considered in the relationship D. The attributes in the tuples are ordered 

  1. In relational algebra, the operator symbol of selection operation is ( )

A .×              B P C σ               D i

  1. Some columns of the relationship are taken out during relational query, and the relational operation of canceling duplicate tuples is ().
  1. Selection operation B. Projection operation C. Connection operation D. Cartesian product
  1. According to the entity integrity rules of the relational schema, a relation's primary key attribute ( ).

A.There can be no two B. cannot be a foreign key of another relation

C.Empty is not allowed D. can take any value

  1. In the relational schema R (R#, RN, S#) and S (S#, SN, SD), the primary key of R is R#, and the primary key of S is S#, then S# is called ( ) in R.
    1. Main code B. Outer code C. Candidate code D. Full code
  2. What kind of integrity constraint ( ) does the constraint "score is between 0-100" belong to.
    1. Primary key constraints B. Foreign key constraints C. User-defined integrity constraints D. None
  3. The relationship R is shown in the figure below, and the image set of a1 is ( ).
    1. {b1,b2 } B. {(b1,c1),(b2,c3)}

A

B

C

a1

b1

c1

a1

b2

c3

a2

b1

c2

C.  {c1,c3}               D. {(b1,c1),(b2,c3), (b1,c2)}

2. Brief description

  1. What are the three components of a relational model?
  2. What are the three types of integrity constraints in relational models?
  3. What relational query operations are provided in relational algebra?

3. Represent queries in relational algebra

  1. The relational database schema for course selection is as follows:

         Student(Sno,Sname,Sage,Ssex)

         Course(Cno,Cname)

       SC(Sno,Cno,Grade)

Express the following query in relational algebra expressions:

  1. Query the student ID number of the students who have taken the No. 2 course
  2. Query the student number and name of the student with the student number "03"
  3. Query the student ID and name of male students who are older than 20 years old
  4. Query the student ID and name of the students who have taken the course
  5. Query the course number and course name of the elective students
  6. Query the names and grades of students who have taken course No. 5
  7. Query the student numbers and names of students who have taken the course "Database Principles"
  1. The existing book lending relational database schema is as follows:

Books (book number, title, author, unit price, inventory)

Reader (reader number, name, work unit, address)

Borrowing (book number, reader number, loan period, repayment period, remarks)

Among them, the repayment period is NULL, indicating that the book has not been returned.

Express the following query in relational algebra:

  1. Query the reader's name and work unit with the reader number "R016"
  2. Query the name of the reader whose book number is "B5"
  3. Query the titles of the books borrowed by the reader "Li Lin"
  4. Query the unreturned titles of the books borrowed by reader "Li Lin"

Principles of Database System Exercises Chapter 3

1. Multiple choice questions

  1. The SQL language is called ( ).

A.Structured Definition Language B. Structured Manipulation Language 

C. Structured Query Language D. Structured Control Language

  1. In the following SQL statement, modify the table structure is ( )

A.CREATE    B.UPDATE     C.INSERT        D.ALTER

  1. 在SELECT语句中, 用于实现数据分组统计的子句是 (  )

A.FROM子句                B.WHERE子句

C.GROUP BY子句            D.ORDER BY 子句

  1. 下列哪种运算不能引出子查询。(  )

   A.IN             B.LIKE          C.EXISTS             D.比较运算   

  1. 基于学生选课数据库中的3个关系:S(学号, 姓名, 性别, 年龄)、C(课程号, 课程名, 任课教师)、 SC(学号, 课程号, 成绩),若要求查找选修“数据库技术”这门课程的学生姓名和成绩,将使用关系( )

A.S和SC        B.SC和C           C.S和C        D.S、SC和C

  1. 基于学生选课数据库中的3个关系:S(学号, 姓名, 性别, 年龄)、C(课程号, 课程名, 任课教师)、 SC(学号, 课程号, 成绩),若要求查找学生的平均成绩大于80分的学号和平均成绩,下面列出的SQL语句,正确的是( )。

A.SELECT 学号, AVG(成绩) FROM SC WHERE AVG(成绩)>80

B.SELECT 学号, AVG(成绩) FROM SC WHERE AVG(成绩)>80 GROUP BY 学号

C.SELECT 学号, AVG(成绩) FROM SC GROUP BY 学号 HAVING AVG(成绩)>80

D.SELECT 学号, 成绩 FROM SC GROUP BY 学号 HAVING AVG(成绩)>80

  1. 下列SQL语句中,正确的是( )。

A.SELECT Sno, SNAME FROM SC GROUP BY Sno

B.SELECT Sno  FROM SC GROUP BY Sno HAVING COUNT(*)>3

C.SELECT Sno  FROM SC GROUP BY Sno WHERE COUNT(*)>3

D.SELECT Sno  FROM SC WHERE COUNT(*)>3 GROUP BY Sno

  1. Operations that cannot be done on a view are ( ).

A.Update the view b. query view

C.Define a new base table on the view D. Define a new view on a view

Two, fill in the blank

  1. In the SQL query statement, use the ( ) clause to specify the data source, use the ( ) clause to select the data rows involved in the operation, and use the ( ) clause to specify the target column. You can use the ( ) clause in combination with aggregate functions for group statistics. If you want to sort the query results, you can use the () clause.
  2. In SQL, the () statement creates tables and declares integrity constraints. If you want to add columns and integrity constraints to a basic table, you should use the ( ) statement. To delete the definition of the table and the data and indexes in the table, the statement that should be used is ( ).
  3. A view is a virtual table defined above ( ), and the view can also be inserted, modified, deleted and queried. But the view does not store data, and all operations on the view will eventually be converted into operations on ( ).

3. Brief description

  1. What are the commonly used operation statements in the SQL language?
  2. What commonly used aggregate functions are provided in SQL? How are they used?
  3. What is a join query? How to specify the connection condition in the connection query?
  4. What is a subquery? How many ways can subquery used in WHERE clause be invoked?

4. Database operation

  1. warehouse management system

In a warehouse management system, there are two tables: KC table and CKMX table,

Its structure and some data are as follows:

Table 1, KC table structure and data

material code

material name

unit

unit price

stock quantity

01

computer

tower

5000.00

10

02

TV set

tower

2000.00

20

Table 2, CKMX table structure and data

serial number

material code

Exit date

Outbound quantity

1

01

2009-10-10

4

2

01

2009-11-20

3

3

02

2009-11-20

5

Among them, the KC table saves the information of the current warehouse inventory materials, and the CKMX table stores the name and details of the inventory materials.

For example, the first line of the KC table indicates that there are 10 existing computers in the warehouse. The second line of the CKMX table indicates that 3 computers were delivered from the warehouse on November 20, 2009.

  1. Try to write the SQL statement to create the KC table and CKMX table, requiring the definition of entities and referential integrity.
  2. Write out the SQL statement to build a unique index by material name on the KC table.
  3. Create a view to query the computer's outbound details.
  4. Write the statement that inserts the data in the table into the corresponding table.
  5. 从表CKMX中统计出各种材料的出库次数和出库总数量,试写出SQL语句。
  6. 写出由KC表和CKMX表产生如下结果集的查询语句:

编号

出库日期

材料名称

单价

出库数量

金额

1

2009-10-10

计算机

5000.00

4

20000.00

2

2009-11-20

计算机

5000.00

3

15000.00

  1. 财务管理系统

学校有多名学生,财务处每年要收一次学费。财务处现用两个表记录相关信息,其结构和部分数据如下表:

表1、XS表结构和数据

学号

姓名

性别

年龄

所在系

200901

张明

18

计算机

200902

王晓萌

21

信息

200903

李刚

20

计算机

表2、JFQK表结构和数据

序号

学号

交费日期

书费

学费

1

200901

2009-09-10

500.50

5000

2

200902

2009-09-10

400.00

5000

3

200901

2010-10-10

300.20

4000

其中,XS表是在校学生名册和基本信息登记表,JFQK表是学生交学费情况记录。

  1. 试写出创建XS表和JFQK表的SQL语句,要求定义实体和参照完整性。
  2. 写出在XS表上按学生姓名建立唯一索引的SQL语句。
  3. 创建一个视图,用于查询计算机系同学的基本信息。
  4. 写出将表中数据插入到相应表中的语句。
  5. 将计算机系同学的年龄增加1岁,并将计算机系同学的学费减1000元。
  6. 从表JFQK中统计出每个同学的交费次数和交费总金额,试写出SQL语句。
  7. 写出由XS表和JFQK表能产生类似如下结果集的查询语句:

序号

姓名

交费日期

书费

学费

合计

1

张明

2009-09-10

500.50

5000

5500.50

2

王晓萌

2009-09-10

400.00

5000

5400.00

数据库系统原理练习题第45

一、选择题

  1. 实体完整性要求主属性不能取空值,这通常是通过( )。

A.DBMS自动保证         B. 用户定义的完整性约束来保证 

C. 定义外键来保证          D. 定义主键来保证

  1. 下列SQL语句中,能够实现参照完整性控制的语句是( )。

A. NOT NULL               B. PRIMARY KEY 

C. UNIQUE                 D. FOREIGN KEY

  1. 若关系R(A,B,C)主码为A, 关系S(D,A)主码为D,外码为A,下面在关系S中哪个元组违反了完整性约束条件?( )。

                            R                        S

A

B

C

D

A

1

2

2

1

3

3

1

2

3

4

2

Null

3

1

A. (1, 2)          B. (2, Null)           C. (3, 3)            D. (4, 1)

  1. 使用CREATE TABLE STU (NO CHAR(4) NOT NULL, NAME CHAR(8) NOT NULL, SEX CHAR(2), AGE INT ) 创建了表STU ,下列哪些语句可以插入到表中。( )

A.INSERT INTO STU VALUES(‘1031’,’张华’,男,23)

B.INSERT INTO STU VALUES (‘1031’,’ 张华’,NULL,NULL)

C.INSERT INTO STU VALUES(NULL,’ 张华’,’男’,23)

D.INSERT INTO STU VALUES (‘1031’,NULL, ’男’,23)

  1. 下列哪种操作不会激活触发器。(  )

A. SELECT         B. UPDATE           C.INSERT         D. DELETE

  1. 在SQL语言中授权的操作是通过( )语句实现的。

A.DELETE        B.UPDATE          C.GRANT         D.REVOKE

二、简述题

  1. 什么是数据库的安全性?数据库系统中常用的安全控制方法和技术有哪些?
  2. 什么是数据库的完整性?关系数据库的完整性包括哪几类?
  3. 什么是触发器?触发器由哪些事件激活?

三、完整性约束定义

1. 设有关系S、SC、C如下:

S(sno, sname, age, sex, sdept)

C(cno, cname, teacher)

SC(sno, cno, score)

用SQL完成下列功能:       

(1)创建学生表S和课程表C(要求标明主码)

(2)创建选修课程情况表SC。(要求标明主码、外码及成绩的范围)

2. 假设有下面两个关系模式:

职工(职工号,姓名,年龄,进校时间,工资,部门号),其中职工号为主码

部门(部门号,部门名称,经理名,电话),其中部门号为主码

用SQL语言定义这两个关系模式,要求在模式中完成以下完整性约束条件的定义:

(1)定义每个模式的主码

(2)定义参照完整性

(3)定义职工年龄不得超过60岁

数据库系统原理练习题第6

一、选择题

  1. 关系数据库规范化是为了解决关系数据库中( )的问题而引入的。

A.提高查询速度

B.插入、删除、更新异常和数据冗余

C.保证数据的安全性和完整性

D.恢复数据库

  1. 关系模式中每个分量都是不可分的数据项,则关系模式属于(  )

A. 1NF                        B. 2NF 

C. 3N                         D. BCNF

  1. 若R∈2NF,则R的每个(  )

A.非主属性部分依赖于码               B.非主属性完全依赖于码

C.主属性部分依赖于码                 D.主属性完全依赖于码

  1. 消除了非主属性对码传递函数依赖的2NF的关系模式,必定属于( )

A.1NF            B.2NF            C. 3NF             D. BCNF

  1. 关系模式中,满足2NF的模式(  )

A.可能是1NF              B.必定是1NF

C.必定是3N               D.必定是BCNF

二、关系模式规范化

1. 设有关系模式: 选修(姓名,专业,课程,任课教师,成绩)

假设:每个学生在一个专业学习;每门课程有一个任课教师;每个学生选修的每门课程只有一个成绩;姓名、课程无重名。

(1)请写出选修关系中存在的基本函数依赖集。

(2)找出关系模式的候选码,指出哪些是主属性?那些是非主属性。

(3)分析关系模式最高属于第几范式?为什么?

(4)如果选修关系不属于3NF,请将其分解为第3NF模式集。

2. 现有一个描述学生、课程以及选课信息的关系模式:

SelectCourse(学号,姓名,年龄,课程名称,成绩,学分)。

其中:每个学生可选多门课程,每门课程只选一次;每个学生选修的每门课程有一个成绩;

         每门课程都规定一定的学分。

(1)请写出SelectCourse关系中存在的基本函数依赖集。

(2)找出关系模式的候选码。

(3)分析关系模式最高属于第几范式?为什么?

(4)请将SelectCourse关系模式分解为第3NF模式集。

3. 假设某商业集团数据库中有一关系模式R如下:

R(商店编号,商品编号,数量,部门编号,负责人)。

如果规定:

(1)每个商店的每种商品只在一个部门销售。

(2)每个商店的每个部门只有一个负责人。

(3)每个商店的每种商品只有一个库存量。

       请回答下列问题:

(1)写出R关系中存在的基本函数依赖集。

(2)找出关系模式的候选码。

(3)分析关系模式最高属于第几范式?为什么?

(4)如果R不属于3NF,请将R分解为第3NF模式集。

数据库系统原理练习题第7

一、选择题

  1. 在数据库设计中,将E-R图转换为关系模式的过程属于(  ) 。

A.需求分析阶段            B.逻辑设计阶段

C.概念设计阶段            D.物理设计阶段

  1. 关系模式中,表示实体间M:N联系是通过增加一个 (  )

A.属性实现          

B.关系实现

C.关系或一个属性实现

D.关系和一个属性实现

  1. 从E-R模型向关系模型转换时,一个M:N的联系转换为一个关系模式,该关系模式的关键字是 (  )

A.M端实体的关键字             

B.N端实体的关键字

C.M端实体的关键字与N端实体的关键字的组合

D.重新选取其它属性

  1. 在E-R模型中,如果有3个不同的实体型,2个M:N联系,根据E-R模型转换为关系模型的规则,转换为关系的数目是。(  )

A.3             B.4                 C.5              D.6

二、简述题

  1. 数据库设计涉及哪些方面的技术和知识?
  2. 数据库设计包括哪几个阶段?
  3. 建立E-R图包括哪几个步骤?

三、数据库设计

1. 某图书馆中图书按类分别存放在多个书库中,可供读者借阅。每个书库中有若干个管理员(这些管理员不再管理其它书库)。请设计一个数据库保存相关的信息。其中:

  1. 书库的属性包括书库编号、位置、面积等, 图书的属性包括书号、书名、出版社等,读者的属性包括读者号、姓名、单位等,管理员的属性包括职工编号、职工姓名等属性;其它属性请自己指定。
  2. 描述借阅关系的属性包括借出日期和应还日期等

试画出书库、图书、读者、管理员及其联系的E-R图(要求注明相关属性及联系的类型), 并将其转换成关系模式(要求注明主码)。

2. 假设一个部门的数据库包括如下信息:

职工的信息:职工号、姓名、地址和所在部门。

部门的信息:部门名称、经理名、电话。

产品的信息:产品编号、产品名、价格、型号。

制造商的信息:厂称、厂址、传真。

另外还包括部门销售产品的信息和制造商生产产品的信息。

试画这个数据库的E-R图(要求注明相关属性及联系的类型), 并将其转换成关系模式(要求注明主码)。

 

Guess you like

Origin blog.csdn.net/weixin_51538341/article/details/128505841