Final Exam Review of Database Management System PDF
Final Exam Review of Database Management System PDF
*************************************
I. Study Guide: 2010/1/6
*************************************
A. General Guideline:
***************************
II. Sample Questions:
***************************
A. Multiple Choice Questions:
(C) 1. Which is not an advantage of using a database system? (A) currency (B) data independence (C) availability
(D) speed
(D) 2. Which is not a component of a database system? (A) data (B) hardware (C) software (D) none of above
(B) 3. Which statement is false?
(A) A database system may support single or many users. (B) Every user has the same view on the database.
(C) The database is integrated (D) The database is shared.
(A) 4. Which is not a level in the three levels fo the architecture?
(A) data level (B) inernal level (C) exernal level (D) coneceptual level
(D) 5. Which is not the job of a database administrator?
(A) participates in conceptual database design (B) determines how to implement conceptual schema
(C) implement security and integrity (D) maintain the computer system
(D) 6. Which is not a function of a DBMS?
(A) data definition (B) data manipulation (C) optimiation and execution (D) none of above
(C) 7. Which is not an explanation of a data dictionary?
(A) data about the data (B) metadata (C) data index (D) none of above
(B) 8. Which is not a component of the relational model?
(A) an open-ended collection of scalar types (B) a relation evaluator
(C) a relational type generator (D) none of above
(A) 9. Which statement is true?
(A) A tuple corresponds to a row in a table.
(B) A relation variable is inherently a specific set of values.
(C) A relation can have different values at different times. (D) none of above
(A) 10. Which is not one of transaction's ACID properties? (A) automaticity (B) consistency (C) isolation (D)
1 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
durability
(D) 11. Which statement is false?
(A) Each attribute of a relation has a name.
(B) Attribute values are (normally) required to be atomic.
(C) The special value null is a member of every domain
(D) none of above
(C) 12. Which is not one of six basic operators of relational algebra? (A) select (B) union (C) set intersection (D)
set difference
(B) 13. Which statement is false?
(A) It is possible for tuples to have a null value.
(B) In SQL "P is null" evaluates to null if predicate P evaluates to null.
(C) null signifies an unknown value or that a value does not exist.
(D) The result of any arithmetic expression involving null is null.
(B) 14. Which is not a DDL command of SQL?
(A) create table (B) select (C) create type (C) alter table
(D) 15. Which is not a operation implemented by the SQL select command?
(A) restrict (B) project (C) join (D) none of above
(B) 16. Which statement is false?
(A) Every database has a catalog.
(B) A catalog has only a schemas.
(C) Each catalog includes one Information Schema
(D) The Information Schema is a collection of all other schemas as views.
(A) 17. Which of the following is not correct?
(A) SQL select operation may be used for data retrieval as well as for data modification.
(B) SQL may be used for data definition as well as data retrieval
(C) SQL may be used fo defining base tables as well as view tables
(D) SQL data definitions may be used for defining primary keys as well as foreign keys.
(C) 18. Which statement is true?
(A) (unknown or true) = unknown (B) (unknown or false) = false
(C) (true and unknown) = unknown (D) (false and unknown) = unknown
Chapter 3: SQL
2 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
3 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
(A) Not reporting statistics to save machine resources (B) Using random index organizations
(C) Clustering data (D) Avoiding indexes on secondary keys
(C) 29. What result will the following SQL statement produce?
Select Avg(standard_price) as average from product_v;
(A) The average price of all products (B) The average of all products in product_v
(C) The average standard_price of all products in product_v (D) None of the above
(B) 30. Which of the following is true of the order in which SQL statements are evaluated?
(A) The group by clause is processed before the where clause.
(B) The select clause is processed before the order by clause.
(C) The select clause is always processed first.
(D) The select clause is always processed last.
(C) 31. Which of the following can produce scalar and vector aggregates?
(A) Order By (B) Having (C) Group By (D) Sort
(D) 32. Which of the following questions is answered by the SQL statement?
Select Count (Product_Description) from Product_T;
(A) How many different columns named "product Description" are there in table Product_T?
(B) How many products are in the Product Table?
(C) How many characters are in the field name "Product_Description"?
(D) How many products have product descriptions in the Product Table?
(D) 33. What result set is returned from the following query?
Select customer_name, telephone from customers where city in ('Boston','New York','Denver');
(A) The customer_name and telephone of all customers living in Boston and New York and Denver
(B) The customer_name and telephone of all customers
(C) The customer_name of all customers living in Boston, New York or Denver
(D) The customer_name and telephone of all customers living in either Boston, New York or Denver
(D) 34. Multiple values returned from an SQL query that includes an aggregate function are called:
(A) scalar aggregates. (B) summations. (C) agates. (D) vector aggregates.
(A) 35. What results will be produced by the following SQL query?
Select sum(standard_price) as total_price from product_v where product_type = 'WOOD';
(A) The total price of all products that are of type wood (B) The total price of all products
(C) The standard_price of any wood product in the table (D) The standard_price of the first wood product in
the table
(D) 36. What does the following SQL statement do?
Alter Table Customer_T Add Type varchar(2.;
(A) Alters the Customer_T table to be a Type 2 Varchar
(B) Alters the Customer_T table by adding a 2-byte field called "Varchar"
(C) Alters the Customer_T table to accept Type 2 Varchars
(D) Alters the Customer_T table, and adds a field called "Type"
(C) 37. Indexes are created in most RDBMSs to:
(A) provide a quicker way to store data.
(B) increase the cost of implementation.
(C) provide rapid random and sequential access to base-table data.
(D) decrease the amount of disk space utilized.
(C) 38. In an SQL statement, which of the following parts states the conditions for row selection?
(A) Select (B) Group By (C) Where (D) From
(C) 39. Which of the following is the wildcard operator in SQL statements? (A) = (B) <> (C) * (D) &
(A) 40. DDL is typically used during which phases of the development process?
(A) Physical design (B) Implementation (C) Analysis (D) All of the above
(D) 41. Which of the following is a purpose of the SQL standard?
(A) To specify minimal and complete standards, which permit different degrees of adoption in products
(B) To specify syntax and semantics of SQL data definition and manipulation
(C) To define the data structures and basic operations for SQL databases
(D) All of the above
4 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
(A) 42. A single value returned from an SQL query that includes an aggregate function is called a(n):
(A) scalar aggregate. (B) summation. (C) vector aggregate. (D) agate.
(C) 43. What does the following SQL statement do?
Delete from Customer_T where state = 'HI';
(A) Deletes all records from the customer_t table (B) Removes the customer_t table from the database
(C) Deletes all records from customer_t where the state is equal to HI (D) None of the above
(D) 44. Which of the following counts ONLY rows that contain a value? (A) Tally(*) (B) Count(*) (C) Checknum
(D) Count
(C) 45. The first in a series of steps to follow when creating a table is to:
(A) create an index. (B) identify columns that must be unique.
(C) identify each attribute and its characteristics. (D) identify columns that must be null.
(D) 46. ________ is a set of commands used to update and query a database. (A) DPL (B) DDL (C) DCL (D)
DML
(C) 47. The SQL command ________ defines a logical table from one or more tables or views.
(A) create table (B) create relationship (C) create view (D) alter table
(C) 48. Which of the following will produce the minimum of all standard prices?
(A) Select min(standard_price) from product_v where standard_price = min(standard_price);
(B) Select standard_price from min(product_v);
(C) Select min(standard_price) from product_v;
(D) Select standard_price from product_v where standard_price = min;
(C) 49. What will be returned when the following SQL statement is executed?
Select driver_no, count(*) as num_deliveries from deliveries where state = 'MA' group by driver_no;
(A) A listing of all drivers who made deliveries to state = 'MA', sorted by driver number.
(B) A count of all of the deliveries made to state = 'MA' by all drivers.
(C) A listing of each driver who made deliveries to state = 'MA' as well as the number of deliveries that each
driver has made to that state.
(D) None of the above.
(C) 50. What does the following SQL statement do?
Update Product_T Set Unit_Price = 775 Where Product_ID = 7
(A) Changes the length of the Unit_Price field to 775 (B) Changes the price of a unit called Product_T to 7
(C) Changes the unit price of Product 7 to 775 (D) Updates the Product_T table to have a unit price of 775
(D) 51. A view may not be updated directly if it contains:
(A) the group by or having clause.
(B) the distinct keyword. (C) derived columns and expressions in the select clause. (D) all of the above.
(C) 52. What will be returned when the following SQL statement is executed?
Select driver_no,count(*) as num_deliveries from deliveries group by driver_no;
(A) A listing of all drivers, sorted by driver number
(B) A count of all of the deliveries made by all drivers
(C) A listing of each driver as well as the number of deliveries that he or she has made
(D) None of the above
(B) 53. ________ is a set of commands used to control a database, which includes security. (A) DPL (B) DCL (C)
DDL (D) DML
(C) 54. What result set will the following query return?
Select item_no from order_v where quantity > 10;
(A) The order_id of all orders that had more than one item
(B) The order_id of all orders that had more than 10 items
(C) The item_no of all orders that had more than 10 items
(D) The item_no of all orders that had 10 or more items
(D) 55. What does the following SQL statement do?
Select * From Customer Where Cust_Type = "Best"
(A) Selects the "*" field from the Customer table for each row with a customer labeled "best"
(B) Selects all the fields from the Customer table for each row with a customer labeled "*"
(C) Selects fields with a "*" in them from the Customer table
5 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
(D) Selects all the fields from the Customer table for each row with a customer labeled "best"
(D) 56. The ________ is the structure that contains descriptions of objects such as tables and views created by
users.
(A) catalog (B) SQL (C) master view (D) schema
(D) 57. To eliminate duplicate rows in a query, the ________ qualifier is used in the SQL Select command.
(A) alter (B) specific (C) check (D) distinct
(B) 58. A ________ view is materialized when referenced. (A) materialized (B) dynamic (C) base (D) virtual
(D) 59. What result set will the following query return?
Select item_no, description from item where weight > 100 and weight < 200;
(A) The item_no for all items weighing more than 200
(B) The item_no for all items weighing between 101 and 199
(C) The item_no and description for all items weighing less than 100
(D) The item_no and description for all items weighing between 101 and 199
(A) 60. Which of the following finds all groups meeting stated conditions?
(A) Having (B) Where (C) Select (D) Find
(B) 61. The SQL command ________ adds one or more new columns to a table.
(A) create table (B) alter table (C) create relationship (D) create view
(D) 62. The benefits of a standardized relational language include:
(A) cross-system communication. (B) reduced training costs. (C) application longevity. (D) all of the above.
(A) 63. What will be returned when the following SQL query is executed?
Select driver_no, count(*) as num_deliveries from deliveries group by driver_no having count(*) > 2;
(A) A listing of all drivers who made more than 2 deliveries as well as a count of the number of deliveries
(B) A listing of all drivers
(C) A listing of all drivers who made more than 2 deliveries
(D) A listing of the number of deliveries greater than 2
(A) 64. What will result from the following SQL Select statement?
Select min(product_description) from product_v;
(A) The first product description alphabetically in product_v will be shown.
(B) The minimum value of product_description will be displayed.
(C) An error message will be generated.
(D) None of the above.
(C) 65. Any create command may be reversed by using a ________ command.
(A) delete (B) unpack (C) drop (D) truncate
6 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
(A) allows one to combine the INSERT and DELETE operations. (B) joins 2 tables together.
(C) allows one to combine the INSERT and UPDATE operations. (D) none of the above.
(A) 6. Explicit commands to manage transactions are needed when:
(A) multiple SQL commands must be run as part of a transaction.
(B) a transaction consists of just one SQL command.
(C) autocommit is set to off.
(D) none of the above.
(B) 7. All of the following are advantages of SQL-invoked routines EXCEPT:
(A) flexibility. (B) security. (C) sharability. (D) efficiency.
(D) 8. A procedure is:
(A) stored within the database. (B) called by name. (C) given a unique name. (D) all of the above.
(D) 9. A join in which the joining condition is based on equality between values in the common columns is called
a(n):
(A) equi-join. (B) uni-lateral join. (C) natural join. (D) both A and C.
(A) 13. A type of join implemented in SQL-1999 and by extension SQL-2003 that returns all of the data from each
table that is joined is called a(n):
(A) union join. (B) inner join. (C) outer join. (D) intersect join.
(A) 14. A join in which rows that do not have matching values in common columns are still included in the result
table is called a(n):
(A) outer join. (B) equi-join. (C) union join. (D) natural join.
(A) 15. Embedded SQL consists of:
(A) SQL written into a front-end application. (B) SQL translated to a lower-level language.
(C) SQL encapsulated inside of other SQL statements. (D) none of the above.
(C) 16. The UNION clause is used to:
(A) join two tables together to form one table.
(B) find all rows that do not match in two tables.
(C) combine the output from multiple queries into a single result table.
(D) none of the above.
(C) 18. A join that is based upon equality between values in two common columns with the same name and where
one duplicate column has been removed is called a(n):
(A) inner join. (B) multivariate join. (C) natural join. (D) equi-join.
(C) 19. ________ takes a value of true if a subquery returns an intermediate results table which contains one or
more rows.
(A) Extents (B) In (C) Exists (D) Having
(C) 22. Establishing IF-THEN-ELSE logical processing within an SQL statement can be accomplished by:
(A) using a subquery. (B) using the immediate if statement.
(C) using the CASE keyword in a statement. (D) using the if-then-else construct.
(A) 23. A named set of SQL statements that are considered when a data modification occurs are called:
(A) triggers. (B) stored procedures. (C) trapdoors. (D) treatments.
(B) 24. A new set of analytical functions added in SQL:2003 are referred to as:
(A) OLAF functions. (B) OLAP functions. (C) average functions. (D) MOLAP functions.
(D) 25. In SQL, a ________ subquery is a type of subquery in which processing the inner query depends on data
from the outer query.
(A) natural (B) paired (C) inner (D) correlated
(A) 26. If the DBA wishes to describe all tables in the database, which data dictionary view should be accessed in
MySQL?
(A) describe (B) list (C) show (D) depict
(B) 27. All of the following are new data types added in SQL:2003 EXCEPT:
(A) MULTISET. (B) BIT. (C) BIGINT. (D) XML.
(B) 28. What results would the following SQL statement produce?
select owner, table_name from dba_tables where table_name = 'CUSTOMER';
(A) A listing of all customers in the customer table
(B) A listing of the owner of the customer table
7 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
8 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
9 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
(C) A member of the superclass can be optionally included as a member of any number of its subclasses.
(D) It is necessary that every entity in a superclass be a member of some subclass
(A) 21. ____ is the process of defining a set of subclasses of a superclass.
(A) Specialization (B) Generalization (C) Aggregation (D) Identification
(B) 22. ____ is the process of grouping a set of subclasses into a superclass.
(A) Specialization (B) Generalization (C) Aggregation (D) Identification
(B) 23. Which is a bottom-up process?
(A) Specialization (B) Generalization (C) Aggregation (D) Identification
(D) 24. An attribute of the superclass that determines the target subclass(es) is called the:
(A) subclass determinant (B) disjoint indicator (C) subclass identification (D) subclass discriminator
(B) 25. If an entity can be a member of at most one of the subclasses of the specialization, the specialization is said
to be:
(A) discrete (B) disjoint (C) united (D) overlapping
(D) 26. If an entity can be a member of at least one of the subclasses of the specialization, the specialization is said
to be:
(A) discrete (B) disjoint (C) united (D) overlapping
(A) 27. The ____ specialization specifies that every entity in the superclass must be a member of some subclass.
(A) total (B) partial (C) disjoint (D) discrete
(B) 28. The ____ specialization specifies that an entity in the superclass is allowed not to belong to any of the
subclasses.
(A) total (B) partial (C) disjoint (D) discrete
(D) 29. Which of the following is a completeness constraint?
(A) Partial instantiation (B) Total association (C) Partial cardinality (D) total specialization
(A) 30. The property by which subclass entities possess all attributes of a superclass is called attribute:
(A) inheritance (B) generalization (C) aggregation (D) identification
(C) 31. In the following figure, to which of the following entities are the entities "CAR" and "TRUCK"
generalized?
10 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
11 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
(C) 45. The attribute ____ is the set of values allowed in an attribute.
(A) schema (B) state (C) domain (D) scope
(B) 46. A subset of the Cartesian product of the domains of its attributes is relation ____.
(A) schema (B) state (C) domain (D) scope
(D) 47. Which is false?
(A) All values in a tuple are considered atomic.
(B) Each value in a tuple must be from the domain of the attribute for that column.
(C) A special null value is used to represent values that are unknown or inapplicable to certain tuples.
(D) The tuples are considered to be ordered.
(C) 48. Which is not a constraint in the relational model?
(A) Key (B) Entity integrity (C) Value (D) Referential integrity
(B) 49. Which is not condition a superkey should satisfy?
(A) No two tuples in any valid relation state will have the same value for superkey.
(B) A superkey should be minimal.
(C) This condition must hold in any valid relational state.
(D) For any distinct tuples the values of superkey are different.
(A) 50. Which is false?
(A) A relation can have only one key.
(B) A key is a minimal superkey.
(C) Any key is a superkey.
(D) Any set of attributes that includes a key is a superkey.
(A) 51. Which is entity integrity?
(A) The primary key cannot have null values.
(B) A relation can have only one key.
(C) If the key values are different, two tuples are different.
(D) Any key is a superkey.
(A) 52. A foreign key is
(A) a key that references a primary key in other relation.
(B) a key that cannot be null.
(C) a key that uniquely identifies different tuples.
(D) a superkey.
(C) 53. Which constraint involves two relations?
(A) Key constraint (B) Entity integrity (C) Referential integrity (D) Domain constraint
(D) 54. Which of the following is the action can be taken in case of integrity violation?
(A) Cancel the operation that causes the violation.
(B) Perform the operation but inform the user of the violation.
(C) Trigger additional updates so the violation is corrected.
(D) All of the above
(A) 55. Which type of solutions to integrity violation does restrict or reject belong to?
(A) Cancel the operation that causes the violation.
(B) Perform the operation but inform the user of the violation.
(C) Trigger additional updates so the violation is corrected.
(D) Execute a user-specified error-correction routine.
(D) 56. Which constraint may insert violate?
(A) Domain constraint (B) Key constraint (C) Referential integrity (D) All of the above
(C) 57. Which constraint may delete violate?
(A) Domain constraint (B) Key constraint (C) Referential integrity (D) All of the above
(D) 58. Which constraint may update violate?
(A) Domain constraint (B) Key constraint (C) Referential integrity (D) All of the above
(D) 1. Which is not an approach to map binary 1:1 relationship types in the ER diagram to the relational schema?
12 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
13 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
1. Briefly explain these terminologies. If they are acronyms, also write what they stand for.
(1) DBA (2) DBMS (2) persistent data (3) data independence (4) DDL (5) relation variable (6) primary key
(7) foreign key (8) predicate (9) true proposition (10) catalog (11) view
Ans:
1. The database administrator (DBA) is the person whose job is to create the actual database and to
14 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
implement the technical controls needed to enforce the various policy decisions made by the data
administrator. The DBA is also responsible for ensuring that the system operates with adequate
performance and for providing a variety of other related technical services.
2. Persistent data is data whose lifetime typically exceeds that of individual application program
executions. In other words, it is data that (a) is stored in the database and (b) persists from the
moment it is created until the moment it is explicitly destroyed. (Nonpersistent data, by contrast, is
typically destroyed implicitly when the application program that created it ceases execution, or
possibly even sooner.)
3. (Physical) data independence is the immunity of applications to changes in storage structure (how the
data is physically stored) and access technique (how it is physically accessed). Note: Logical data
independence is discussed in Chapters 2, 3, and especially 10. See also Appendixes A and D. Logical
data independence means users and user programs are immune to changes in the logical structure of
the database (meaning changes at the conceptual or "community logical" level). Physical data
independence means users and user programs are immune to changes in the physical structure of the
database (meaning changes at the internal or stored level). A good DBMS will provide both.
4. A data definition language (DDL) is a language for defining, or declaring, database objects.
5. Relation variables (relvars) are variables; they can thus be "read" and updated, by definition.
6. The primary key of a given relvar is a column or combination of columns in that relvar whose values
can be used to identify rows within that relvar uniquely (in other words, it's a unique identifier for the
rows of that relvar).
7. A foreign key is a column or combination of columns in one relvar whose values are required to
match those of the primary key in some other relvar (or possibly in the same relvar).
8. A predicate is a truth-valued function. Every relation has a corresponding predicate that defines
(loosely) "what the relation means." Each row in a given relation denotes a certain true proposition,
obtained from the predicate by substituting certain argument values of the appropriate type for the
parameters of the predicate ("instantiating the predicate").
9. A true proposition is, loosely, something that evaluates to true, unequivocally.
10. The catalog is a set of system relvars whose purpose is to contain descriptors regarding the various
objects that are of interest to the system itself, such as base relvars, views, indexes, users, integrity
constraints, security constraints, and so on.
11. A (relational) view, also known as a virtual relvar, is a named derived relvar. Views are virtual, in the
sense that they don't have any existence apart from the base relvars from which they're derived (but
users should typically not be aware that a given view is in fact virtual in this sense, though SQL falls
very short in this regard, owing to its weak support for view updating). Operations on views are
processed by translating them into equivalent operations on those underlying base relvars.
2. 1. What is a database?
2. What is a database system?
3. List two advantages of using a database system.
4. List two disadvantages of using a database system.
Ans:
1. A database is a repository for a collection of computerized data files. (At least, this would be the
normal definition. A much better definition is: A database is a collection of propositions, assumed by
convention to be ones that evaluate to TRUE. See reference [1.2] for further explanation.)
2. A database system is a computerized system whose overall purpose is to maintain a database and to
make the information in that database available on demand. (As in the body of the chapter, we
assume for simplicity, here and throughout these answers, that all of the data in the system is in fact
kept in just one database. This assumption is very unrealistic in practice.)
3. Some of the advantages of using a database system are as follows:
Compactness
Speed
Less drudgery
Currency
15 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
Centralized control
Data independence
4. Some of the disadvantages are as follows:
Security might be compromised (without good controls).
Integrity might be compromised (without good controls).
Additional hardware might be required.
Performance overhead might be significant.
Successful operation is crucial (the enterprise might be highly vulnerable to failure).
The system is likely to be complex (though such complexity should be concealed from the
user).
3. 1. What is an entity?
2. What is a relationship?
3. What is a relational system?
Ans:
1. An entity is any distinguishable person, place, or thing that is deemed to be of interest for some
reason. Entities can be as concrete or as abstract as we please.
2. A relationship (q.v.) is a special kind of entity. (As with relationships, we really need to distinguish
between entity types and entity occurrences or instances, but in informal contexts the same term
entity is often used for both concepts.)
3. A relational system is a system that is based on the relational model. Loosely speaking, therefore, it is
a system in which:
1. The data is perceived by the user as tables (and nothing but tables).
2. The operators at the user's disposal (e.g., for data retrieval) are operators that generate new
tables from old.
16 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
queried as if it did.
9. Consider the following two database tables. Use the SQL command to get a list the first name and last name
of customers who have more than $5000 in their account.
Coustomer table:
+-------------+-----------+----------+------------+
| customer_no | firstname | lastname | account_no |
+-------------+-----------+----------+------------+
| 1 | Mike | Nichols | 102 |
| 2 | Jay | Leno | 202 |
| 3 | John | Wayne | 302 |
| 4 | Tim | Allen | 402 |
+-------------+-----------+----------+------------+
Account:
+------------+---------+
| account_no | balance |
+------------+---------+
| 102 | 5000.00 |
| 202 | 7000.00 |
| 302 | 6000.00 |
| 402 | 4000.00 |
+------------+---------+
Ans:
select firstname, lastname
from Customer, Account
where Customer.account_no = Account.account_no
and balance > 5000;
17 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
1. How can you add an attribute - publisher into the Books table?
2. How can you drop the attribute - publisher from the Books table?
3. Write an SQL query that will return the idns of authors who have written any book that is not of
TYPE 'fiction'
4. Write two significantly different SQL queries that will return the idns of authors who have not written
any book that is of TYPE 'fiction'.
5. Write an SQL query that will return the isbns of books written by more than one author.
6. Write an SQL query that will return the idns of authors along with the number of books written by
each author.
Ans:
1. alter table Books add publisher VARchar(20);
2. alter table Books drop publisher;
3. select idn from Authors, Books
where Authors.isbn=Books.isbn and type <> 'fiction';
18 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
select idn from Authors except (select idn from Authors A, Books B where A.isbn=B.isbn and
B.type='fiction')
4. select isbn from Authors A where exists (select * from Authors where A.isbn=isbn and A.idn<>idn)
5. select isbn from Authors AS A1, Authors AS A2 where A1.isbn=A2.isbn and A1.idn<>A2.idn)
6. select idn, count(isbn) from Authors group by idn
12. Modify the following declaration of table Authors to declare a constraint that isbn in Authors has a foreign
key which refers to isbn of Books.
create table Authors ( idn char(9), isbn char(20), primary key (idn, isbn), foreign key isbn references
Books(isbn) );
create table Authors ( idn char(9), isbn char(20) references Books(isbn), primary key (idn, isbn) );
13. Modify the following declaration of table Authors to declare an attribute-based check constraint that isbn in
Authors should have a value that is the same as the isbn in some tuple from Books.
create table Authors ( idn char(9), isbn char(20), primary key (idn, isbn) );
create table Authors ( idn char(9), isbn char(20) check (isbn in (select isbn from Books)), primary key (idn,
isbn) );
14. Consider the following relational database:
For each of the following queries, give an expression in relational algebra and SQL.
1. Find the names of all employees who work for First Bank Corporation.
2. Find the names and cities of residence of all employees who work for First Bank Corporation.
3. Find the names, street address, and cities of residence of all employees who work for First Bank
Corporation and earn more than $10,000 per annum.
4. Find the names of all employees in this database who do not work for First Bank Corporation.
5. Find the names of all employees who earn more than every employee of Small Bank Corporation.
6. Assume the companies may be located in several cities. Find all companies located in every city in
which Small Bank Corporation is located.
7. Find the names of all employees in this database who live in the same city as the company for which
they work.
8. Find the names of all employees who live in the same city and on the same street as their managers.
Ans:
1. π employee-name (σ company-name = "First Bank Corporation" (works))
select employee_name from works where company name = 'First Bank Corporation';
3. We assume each person works for at most one company. If people may work for several companies,
the following solutions will only list those who earn more than $10,000 per annum from "First Bank
Corporation" alone.
π employee-name, street, city ( (σ (company-name = "First Bank Corporaton" ∧ salary > 10000) works |X| employee)
19 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
4. The following solutions assume that all people work for exactly one company. If one allows people to
appear in the database (e.g. in employee) but not appear in works, or if people may have jobs with
more than one company, the problem is more complicated. We give solutions for this more realistic
case later.
select employee_name from works where company_name <> 'First Bank Corporation'
5. The following solutions assume that all people work for at most one company.
6. Assume the companies may be located in several cities. Find all companies located in every city in
which Small Bank Corporation is located.
Note: Small Bank Corporation will be included in each answer.
1. Give an SQL DDL definition of this database. Identify referential-integrity constraints that should
hold, and include them in the DDL definition.
2. Write check conditions to ensure that
1. Every employee works for a company located in the same city as the city in which the
employee lives.
2. No employee earns a salary higher than that of his manager.
20 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
Ans:
1. create table employee (
employee_name char(20),
street char(30),
city char(30),
primary key (person name))
2. 1. check((employee_name, company_name) in
(select e.employee_name, c.company_name
from employee e, company c
where e.city = c.city))
16. The database of a for a library which can store the information of members, borrow, and books. The
database schema of the library is shown as follows:
member (member_no, name, address, phone, email)
borrow (isbn, member_no, checkout_date, borrow_period
book (isbn, book_title, authors)
1. Draw a entity-relationship diagram.
2. Draw a relational schema diagram specifying the foreign keys for this schema.
1.
2. member
21 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
1. The disjointness constraint specifies that the subclasses of the specialization must be disjoint.
The overlapping specialization specifies that the subclasses of the specialization can be
overlapping.
The total specialization specifies that every entity in the superclass must be a member of some
subclass.
The partial specialization specifies that an entity in the superclass is allowed not to belong to
any of the subclasses.
2. A shared class is the intersection of its superclasses while a category is a subset of the union of its
superclasses.
18. Draw an EER diagram for the following bank.
A bank has three types of accounts: checking, savings, and loan. The attributes of each account are shown
as follows:
Checking: Account_No, Date_Opened, Balance, Service_Charge
Savings: Account_No, Date_Opened, Balance, Interest_Rate
Loan: Account_No, Date_Opened, Balance, Interest_Rate, Payment
Account_type is used to identify the type of accounts.
Assume the account in the bank can be only one of its subclasses.
Ans:
19. Consider a Grade Report table that has the following functional dependencies:
22 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
23 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
24 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
23. 1. Choose an object and create an XML document to specify the information about this object.
2. Create a DTD file to specify the elements in this XML document.
3. Create a XSD file to specify the elements in this XML document.
4. Create an XSL file to display this XML document.
5. Include the XSL file in the Question 4 in this XML document
Hint: You can use the following information to create XML, DTD, CSS, and XSL documents.
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "InternalNote.dtd">
<!DOCTYPE note [
<!ELEMENT payment (#PCDATA)>
<!ATTLIST payment type CDATA "check">
]>
<link rel="stylesheet" type = "text/css" href="simple.css">
<?xml-stylesheet type="text/xsl" href="simple.xsl" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="concerts" minOccurs="1" maxOccurs="unbounded" />
<xsd:sequence>
<xsd:element name="performer" type="xsd:string"/>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<xsl:for-each select="classmates/classmate">
<xsl:value-of select="lastname"/>
Ans:
1. <?xml version="1.0"?>
<concerts>
<concert>
<performer>Celine Dion</performer>
<place>Wichita Studium</place>
<date>2003-1-10</date>
</concert>
<concert>
<performer>Paul McCartney</performer>
<place>Kansas Studium</place>
<date>2003-1-20</date>
</concert>
</concerts>
2. <!DOCTYPE concerts [
<!ELEMENT concerts (concert)>
<!ELEMENT cconcert (performer, place, date)>
<!ELEMENT performer (#PCDATA)>
<!ELEMENT place (#PCDATA)>
<!ELEMENT date (#PCDATA)>
]>
25 of 26 6/5/2012 10:40 PM
Final Exam Review of Database Management System http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...
<xsl:template match="/">
<html>
<body>
<table>
<tr>
<th>Performer</th>
<th>Place</th>
<th>Date</th>
</tr>
<xsl:for-each select="concerts/concert" order-by="+ date">
<tr>
<td><xsl:value-of select="performer" /></td>
<td><xsl:value-of select="place" /></td>
<td><xsl:value-of select="date" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
5. <?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="concert.xsl" ?>
<concerts>
<concert>
<performer>Celine Dion</performer>
<place>Wichita Studium</place>
<date>2003-1-10</date>
</concert>
<concert>
<performer>Paul McCartney</performer>
<place>Kansas Studium</place>
<date>2003-1-20</date>
</concert>
</concerts>
26 of 26 6/5/2012 10:40 PM