Sunteți pe pagina 1din 26

Final Exam Review of Database Management System

http://wcla.csie.chu.edu.tw/course/database-system/exam/database-system...

************************************* I. Study Guide: 2010/1/6 ************************************* A. General Guideline: 1. Study the summary in each chapter. 2. Study the lecture notes. 3. Study the homeworks. 4. Study those examples discussed in the class. 5. Study the textbook. 6. Study this study guide. 7. Try the quizzes at http://www.w3schools.com/. 8. Study the exercises in the textbook. B. Review for the Final Exam: 1. Understand the basis of database management. (Chapter 1) 2. Understand the relational model. (Chapter 2) 3. Understand SQL. (Chapter 3) 4. Understand advanced SQL. (Chapter 4) 5. Understand database design and the E-R model (Chapter 5) 6. Understand relational database design (Chapter 6) 7. Understand XML (Chapter 10) *************************** II. Sample Questions: *************************** A. Multiple Choice Questions: Chapter 1 - 2: Introduction, Relational Model (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 (B) 1. What does SQL stand for? (A) Standard Query Language (B) Structured Query Language (C) Semantic Query Language (D) Syntax Query Language (D) 2. Which is not a category of SQL? (A) DDL (B) DML (C) DCL (D) DAL (C) 3. Which is not a SQL command? (A) delete (B) insert (C) search (D) update (D) 4. Which is not a DDL command? (A) alter table (B) create table (C) drop table (D) select table (B) 5. Which is not a DML command? (A) delete (B) drop table (C) insert (D) update (A) 6. Which of the following is to use alter a table? (A) DDL (B) DML (C) DCL (D) DAL (B) 7. Which of the following is to use update a table? (A) DDL (B) DML (C) DCL (D) DAL (B) 8. Which is a set of commands used to update and query a database? (A) DDL (B) DML (C) DCL (D) DAL (B) 9. Which of the following is not a DML command? (A) insert (B) create table (C) delete (D) select (C) 10. To delete a table, which SQL command can be used? (A) delete (B) unpack (C) drop (D) truncate (C) 11. How many attributes will be shown in the following query? select student_no, name, department, address, email (A) 3 (B) 4 (C) 5 (D) 6 (A) 12. In select student_no, score from the grade_report table where course_no = 'CS02208', what is course_no = 'CS02208'? (A) A condition (B) A list of attribute names (C) A list of the relation names (D) None of the above (B) 13. What result set will the following query return?

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...

select item_no from order where quantity > 20; (A) The order_id of all orders that had more than 20 items. (B) The item_no of all orders that had more than 20 items. (C) The order_id of all orders that had more than one item. (D) The item_no of all orders that had 20 or more items. (D) 14. Which can be used to select the student's number whose score is greater than or equal to 60 from the grade_report table? (A) select student_no from report where score <= 60. (B) select student_no from report where score > 60 (C) select student_name from grade_report where score >= 60. (D) select student_no from grade_report where score >= 60 (A) 15. To eliminate duplicate rows in a query, the ________ qualifier is used in the SQL Select command. (A) distinct (B) check (C) alter (D) specific (D) 16. The SQL command ________ adds one or more new columns to a table. (A) create relationship (B) create view (C) create table (D) alter table (D) 17. Indexes are created in most RDBMSs to: (A) provide a quicker way to store data. (B) decrease the amount of disk space utilized. (C) increase the cost of implementation. (D) provide rapid random and sequential access to base-table data. (B) 18. What result set will the following query return? select item_no, description from item where price >= 100 and price <= 200; (A) The item_no for all items costing between 100 and 200 (B) The item_no and description for all items costing between 100 and 200 (C) The item_no and description for all items costing less than 100 (D) The item_no and description for all items costing more than 200 (A) 19. In an SQL statement, which of the following parts states the conditions for row selection? (A) where (B) select (C) from (D) in case (B) 20. What does the following SQL statement do? delete from customer where city = 'Hsinchu'; (A) Deletes all records from the customer table. (B) Deletes all records from customer where the city is equal to Hsinchu. (C) Removes the customer table from the database. (D) None of the above (B) 21. DDL is typically used during which phases of the development process? (A) Analysis (B) Physical design (C) Implementation (D) All of the above (A) 22. Which of the following is the wildcard operator in SQL statements? (A) * (B) <> (C) = (D) & (B) 23. Which is a aggregate function that returns the number of tuples or values as specified in a query? (A) avg (B) count (C) min (D) sum (C) 24. Which provides a condition on the group of tuples associated with each value of the grouping attributes? (A) exit (B) in (C) having (D) with (B) 25. Which can be used to increase the 10% interest rate for all accounts in the account table? (A) update account where interest = 0.1; (B) update account set interest = 1.1 * interest; (C) udpate interest * 1.1 from account (D) None of the above (B) 26. Which of the following is true about the SQL statement Select * From Product Where Quantity = 1 Or Quantity = 2; (A) All fields will be selected from the Product table for products that have a quantity of 1. (B) All fields will be selected from the Product table for products that have a quantity of 1 or 2. (C) All fields will be selected from the Product table for products that have a quantity of only 2. (D) None of the above. (D) 27. To get all the customers from Hawaii sorted together, which of the following would be used? (A) Having (B) Group By (C) Sort (D) Order By (C) 28. Which of the following is a technique for optimizing the internal performance of the relational data model?

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 Chapter 4: Advanced SQL (C) 1. One major advantage of the outer join is that: (A) the query is easier to write. (B) information is easily accessible. (C) information is not lost. (D) all of the above. (C) 2. A join operation: (A) brings together data from two different fields. (B) causes two disparate tables to be combined into a single table or view. (C) causes two tables with a common domain to be combined into a single table or view. (D) is used to combine indexing operations. (D) 3. User-defined data types: (A) can be a subclass of a standard type. (B) can have defined functions and methods. (C) can behave as an object. (D) can have all of the above. (C) 4. In order for two queries to be UNION-compatible, they must: (A) both return at least one row. (B) both have the same number of lines in their SQL statements. (C) both output compatible data types for each column and return the same number of rows. (D) all of the above. (C) 5. The MERGE command:

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...

(C) An error message (D) A listing of the owner of the customer table as well as customers (B) 29. While triggers run automatically, ________ do not and have to be called. (A) selects (B) routines (C) trapdoors (D) updates (B) 30. User-defined transactions can improve system performance because: (A) speed is improved due to query optimization. (B) transactions are processed as sets, reducing system overhead. (C) transactions are mapped to SQL statements. (D) all of the above. (A) 33. A _________ is a temporary table used in the FROM clause of an SQL query. (A) derived table (B) correlated subquery (C) view table (D) none of the above (B) 34. A type of query that is placed within a WHERE or HAVING clause of another query is called a: (A) master query. (B) subquery. (C) multi-query. (D) superquery. Chapter 5: Database design and the E-R model (B) 1. Which is the first step of database design? (A) logic design (B) requirements collection and analysis (C) physical design (D) transaction implementation (D) 2. Which is in DBMS-independent design process? (A) application program (B) transaction implementation (C) physical (D) functional analysis (D) 2. Which is not a type of attributes? (A) Simple (B) Composite (C) Multi-valued (D) Parametic (A) 3. ____ are specific objects or things in the mini-world that are represented in the database. (A) Entities (B) Attributes (C) Relationships (D) Descriptions (C) 4. A property or characteristic of an entity type that is of interest to the organization is called a(n): (A) relationship. (B) coexisting entity. (C) attribute. (D) cross-function. (B) 5. A person's name, birthday, and social security number are all examples of : (A) Entities (B) Attributes (C) Relationships (D) Descriptions (D) 6. An attribute that can be broken down into smaller parts is called a(n) ____ attribute. (A) simple (B) associative (C) complext (D) composite (A) 7. The total quiz points for a student for an entire semester is a(n) ____ attribute. (A) derived (B) stored (C) mixed (D) addressed (C) 8. A(n) _____ relationship is the relationship between a weak entity type and its owner. (A) key (B) member (C) identifying (D) main (C) 4. ___ is the current state of the entities of that type that are stored in the database. (A) Entity type (B) Entity instance (C) Entity set (D) Entity (D) 5. Which is not the main concepts in ER model? (A) Entities (B) Attributes (C) Relationships (D) Identifications (C) 6. A ____ relates two or more distinct entities with a specific meaning. (A) Entities (B) Attributes (C) Relationships (D) Identifications (C) 7. The ____ of a relationship type is the number of participating entity types. (A) cardinality (B) identification (C) degree (D) participation (A) 8. Relationship types of degree 3 are called ____. (A) ternary (B) primary (C) tertiary (D) binary (D) 9. A(n) ________ specifies the number of instances of one entity that can be associated with each instance of another entity. (A) degree (B) counter constraint (C) limit (D) cardinality constraint (C) 10. In (student_no, name, address(street, city, state, zipcode)), address is (A) a derived attribute. (B) a multivalued attribute. (C) a composite attribute. (D) a relational attribute. (B) 11. Which is false? (A) Relationship type is grouped by the same type of relationships. (B) The current state of a relationship type is the relationship set. (C) Relationship type identifies the relationship name and the participating entity types.

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...

(D) Relationship type identifies certain relationship constraints. (D) 12. Which is false? (A) A relationship can have one or more attributes. (B) A weak entity must participate in an identifying relationship type with an owner or identifying entity type. (C) Cardinality Ratio specifies maximum participation. (D) An attribute relate two entities. (A) 13. An entity type whose existence depends on another entity type is called a(n) ________ entity. (A) weak (B) codependent (C) identifying (D) strong (D) 14. An attribute that uniquely identifies an entity is called a(n) ____ attribute. (A) weak (B) relationship (C) identifying (D) key (C) 15. In the following diagram, which answer is true?

(A) Each employee can manage many departments. (B) Each employee works in more than one department. (C) Each employee can supervise one to many employees. (D) All of the above. (A) 16. A student can attend 5 courses. Different professors can offer the same courses. The relationship of students to professors is a ________ relationship. (A) many-to-many (B) one-to-many (C) one-to-one (D) many-to-one (A) 17. Which is not a section in a UML class? (A) class relationship (B) class name (C) class attributes (D) class operations (B) 18. Which is a database design tool? (A) Visual Studio (B) Visio Enterprise (C) MySQL (D) none of the above (C) 19. Which is false? (A) EER stands for Enhanced ER or Extended ER. (B) The EER can model applications more completely and more accurately. (C) The EER is a type of implementation data models. (D) The EER includes some object-oriented concepts, such as inheritance. (D) 20. Which is false? (A) The superclass/subclass relationships are also called IS-A relationships. (B) An entity cannot exist in the database merely by being a member of a subclass.

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?

(A) Tonage (B) Price (C) VEHICLE (D) Vehicle_id (C) 32. In the following figure, which is true?

(A) An employee must be a secretary, a technician, or a engineer. (B) An employee must be a secretary, a technician, and a engineer.

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...

(C) An employee need not to be a secretary, a technician, or a engineer. (D) A secretary can be an engineer. (D) 33. Which is false? (A) A shared subclass have more than one distinct superclass/subclass relationships. (B) In a shared subclass each relationship has a single superclass. (C) A shared subclass leads to multiple inheritance. (D) A shared subclass can have only one superclass. (C) 34. A(n) ____ member must exist in at least one of its superclasses. (A) intersection (B) shared (C) category (D) selection (B) 35. In the following figure, which is true?

(A) The owner class is a shared subclass. (B) An owner must must be at least a bank, a person, or a company. (C) An owner must be a bank, a person, and a company. (D) An owner need not be either one of a bank, a person, and a company. (A) 36. Which use conceptual modeling and other tools to develop "a specification of a conceptualization"? (A) Ontologies (B) Topologies (C) Technlogies (D) Geologies (D) 37. ____ refers to the language and vocabulary (data model concepts) used. (A) Assertion (B) Conceptualization (C) Generalization (D) Specification (B) 38. ____ refers to the description (schema) of the concepts of a particular field of knowledge and the relationships among these concepts. (A) Assertion (B) Conceptualization (C) Generalization (D) Specification (B) 39. What does the strength of the relational approach to data management comes from? (A) higher adaptability and productivity. (B) the formal foundation provided by the theory of relations. (C) better concurrency control. (D) ease of conversion to any new approach. (A) 40. What mathematical concept is a relation based on? (A) set (B) vector (C) difference (D) matrix (C) 41. Who first proposed the relation model? (A) Peter Chen (B) C. J. Date (C) E. F. Codd (D) None of the above (D) 42. Which is false? (A) A relation looks like a table of values. (B) A relation typically contains a set of rows. (C) In a relation rows are called tuples. (D) Each row has a row header called an attribute. (D) 43. In each row a value of a data item (or set of items) that uniquely identifies that row in the table is called ____. (A) tuple (B) set (C) column (D) attribute (A) 44. The key that is generated by the DBMS is called ____ key. (A) artificial (B) automatic (C) automic (D) access

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 Chapter 7: Relational Database Design (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...

(A) Foreign Key (B) Merged relation (C) Cross-reference or relationship relation (D) Functional relation (A) 2. Which is the approach to map a M:N relationship type in the ER diagram to the relational schema? (A) A relationship relation and two foreign keys (B) Merged relation option (C) Set of simple component attributes (D) Functional relation (C) 3. Which is the approach to map a n-ary relationship type in the ER diagram to the relational schema? (A) Set of simple component attributes (B) Merged relation option (C) A relationship relation and n foreign keys (D) Functional relation (B) 4. Which is the approach to map a composite attribute in the ER diagram to the relational schema? (A) Foreign key (B) Set of simple component attributes (C) A relation and foreign key (D) None of the above (C) 5. Which is the approach to map a multivalued attribute in the ER diagram to the relational schema? (A) Foreign key (B) Set of simple component attributes (C) A relation and foreign key (D) None of the above (D) 6. Which is a measure of quality for relation schema design? (A) Semantics of the attributes (B) Reducing the redundant information in tuples (C) Reducing the NULL values in tuples (D) All of the above (B) 7. The _____ of a relation refers to the interpretation of attribute values in a tuple. (A) instance (B) semantics (C) syntax (D) ontology (D) 8. What problems could information is stored redundantly in a database? (A) Insertion anomalies (B) Deletion anomalies (C) Modification anomalies (D) All of the above (C) 9. Which is not a reason for nulls? (A) Attribute is not applicable or invalid. (B) Attribute value is unknown (may exist). (C) The value is beyond the domain range. (D) Value is known to exist, but unavailable. (A) 10. Which of following constraints applies to two attributes? (A) functional dependency. (B) attribute dependency. (C) functional relation constraint. (D) functional relation. (D) 11. Which statement is false? (A) Functional dependencies (FDs) are used to specify formal measures of the "goodness" of relational designs. (B) Functional dependencies and keys are used to define normal forms for relations. (C) Functional dependencies are constraints that are derived from the meaning and interrelationships of the data attributes (D) If the attribute X determines the attribute Y, X is functionally dependent on Y. (D) 12. What is not a Armstrong's inference rule? (A) Reflexive (B) Augmentation (C) Transitive (D) Associative (B) 13. _____ is the process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations. (A) Generalization (B) Normalization (C) Realization (D) Specialization (A) 14. _____ is the process of storing the join of higher normal form relations as a base relation. (A) Denormalization (B) Generalization (C) Realization (D) Specialization (C) 15. Which is true? (A) A superkey is a key. (B) Two tuples can have the same key value. (C) A relation can have more than one candidate key. (D) None of the above (D) 16. Which is not a property of the first normal form? (A) There are no composite attributes. (B) There are no multivalued attributes. (C) There are no nested relations. (D) There is no transitive functional dependency. (B) 17. A relation that contains no multivalued attributes, and has nonkey attributes solely dependent on the primary key, but contains transitive dependencies is in which normal form? (A) First (B) Second (C) Third (D) Fourth (C) 18. A functional dependency between two or more nonkey attributes is called a:

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...

(A) partial nonkey dependency. (B) partial transitive dependency. (C) transitive dependency. (D) partial functional dependency. (C) 19. In which normal form there is no transitive functional dependency? (A) First (B) Second (C) Third (D) Fourth (B) 20. In which normal form is a relation schema R if whenever an FD X A holds in R, then X is a superkey of R? (A) Third (B) Boyce-Codd Normal Form (BCNF) (C) Fourth (D) Fifth Chapter 10: XML (C) 1. What does XML stand for? (A) Example Markup Language (B) eXtra Modern Link (C) eXtensible Markup Language (D) X-Markup Language (C) 2. Which is not a legal XML element name? (A) name (B) first-name (C) 007 (D) luck7 (B) 3. Which XML element is incorrect? (A) <br/> (B) <br> (C) <name>Tom</name> (D) <author></author> (D) 4. Which can be used to specify the data type of an XML element? (A) CSS (B) XSL (C) HTML (D) DTD (A) 5. In DTD, which modifier indicates that there are more than one element? (A) + (B) * (C) ? (D) " (B) 6. In DTD, how do we specify every attribute has the assigned value? (A) #FIXED (B) #REQUIRED (C) #IMPLIED (D) #DEFAULT (D) 7. Which is not a reason to use an entity in XML? (A) Large documents are easier to manage. (B) Repeated entities need not be literally repeated. (C) Binary entities can only be referenced in the document entities. (D) none of the above (A) 8. Which is true? (A) XML can be used to define other markup language. (B) XML is used to display a document. (C) XML is used to replace HTML. (D) An XML document can use XSD to present its content. (B) 9. What is the correct syntax of the declaration which defines the XML version? (A) <xml version="1.0" /> (B) <?xml version="1.0"?> (C) <?xml version="1.0" /> (D) none of the above (B) 10. Which statement is true? (A) All XML elements must be lower case. (B) All XML elements must be properly closed. (C) All XML documents must have a DTD. (D) none of the above (A) 11. An XML parser performs what function? (A) dissects and interprets XML elements (B) dissects and interprets HTML documents (C) dissects and interprets Word documents (D) dissects and interprets HTML files (D) 12. When you modify an XML file, what must you do to display the changes? (A) modify the HTML file (B) modify the DHTML file (C) modify the XML file (D) modify the CSS file (B) 13. What term is XSL short for? (A) eXtensible Standard Language (B) eXtensible Style Language (C) eXtensive Style Language (D) eXtensive Standard Language (D) 14. What is a correct way of referring to a stylesheet called "mystyle.xsl" ? (A) <link type="text/xsl" href="mystyle.xsl" /> (B) <style type="text/xls" href="mystyle.xsl" /> (C) <stylesheet type="text/xsl" href="mystyle.xsl" /> (D) <?xml-stylesheet type="text/xsl" href="mystyle.xsl" ?> B. Question and Answer: 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...

2.

3.

4. 5. 6.

7. 8.

9. 10.

11.

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. 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.) (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. A data definition language (DDL) is a language for defining, or declaring, database objects. Relation variables (relvars) are variables; they can thus be "read" and updated, by definition. 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). 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). 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"). A true proposition is, loosely, something that evaluates to true, unequivocally. 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. 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. What is a database? What is a database system? List two advantages of using a database system. List two disadvantages of using a database system.

2.

1. 2. 3. 4. 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. 2. 3. Ans: 1. What is an entity? What is a relationship? What is a relational system?

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. Describe the three levels of the architecture. What is a DBMS? List 5 major functions performed by the DBMS.

4.

The internal level (storage level) is the one closest to physical storage. The external level (user logical level) is the one closest to the users. The conceptual level (community logical level) is a level of indirection between the other two. 2. A database management system (DBMS) is the software that handles all access to the database. 3. The major functions performed by the DBMS include: Data definition support Data manipulation support Data security and integrity support Data recovery and concurrency support Data dictionary support 5. List six major steps that you would take in setting up a database for a particular enterprise. 1. Define the high level requirements of the enterprise (this step generates a document known as the system requirements specification.) 2. Define a model containing all appropriate types of data and data relationships. 3. Define the integrity constraints on the data. 4. Define the physical level. 5. For each known problem to be solved on a regular basis (e.g., tasks to be carried out by clerks or Web users) define a user interface to carry out the task, and write the necessary application programs to implement the user interface. 6. Create/initialize the database. 6. Describe the difference between tables and views. Ans: A table is a stored relation, while a VIEW is a virtual relation, which does not exist physically, but can be

1. 2. 3. Ans: 1.

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. 7. 1. 2. 3. 4. Ans: 1. What are 6 basic operators of relational algebra? Derive the set intersection from the six basic operations of relational algebra. Explain the natural-join operation. Explain the division operation

Six basic operators: select: project: union: set difference: - Cartesian product: x rename: 2. The definition of set intersection is r s = {t | t r and t s}. r - (r - s) = r - {t | t r and t s} = r and t s}= r s. {t | t 3. The natural join is a join of two tables that returns tuples for which there are matching values in the common attributes on which the tables are joined and redundant columns are eliminated. 4. The division operation is a binary operation. The schema of the second relational variable is included in the schema of the first relation variable. Only those tuples in the first relation which has the same values as in the second relation for the corresponding attributes are selected but only those values in the attributes that are additional to the second relation are projected. 8. Use the SQL command to create a table specifying a course including the following information: the course identification, the course title, the credit hours, the instructor, the schedule, and the classroom. Ans:
create table course ( course_id varchar(10), course_title varchar(25), hours integer, instructor varchar(25), schedule varchar(15), classroom varchar(19) );

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...

10. Consider a banking database with the following relation schemas:


branch (branch_name, branch_city, assets) customer (customer_name, customer_street, customer_city) account (account_number, branch_name, balance) loan (loan_number, branch_name, amount) depositor (customer_name, account_number) borrower (customer_name, loan_number)

Use relation algebra and SQL to write the following queries: Example: Find all loans of over $1200. Ans:samount > 1200 (loan) select * from loan where amount > 1200; 1. Find all loans of over $1200 at the Perryridge branch. 2. Find the names of all customers who meet the following criteria: 1. They are both a borrower and depositor. 2. Both their loan and balance are over $1200. Ans: 1. s branch_name = 'Perryridge' ^ amount > 1200 (loan) select * from loan where branch_name = 'Perryridge' and amount > 1200; 2. customer_name (s balance > 1200 (depositor |X| account )) n ?customer_name (s amount > 1200 (borrower |X| loan)) select customer_name from borrower, depositor, loan, account where (borrower.customer_name = depositor.customer_name) and (loan.branch_name = account. branch_name) and (loan.amount > 1200 and account.balance > 1200); Note: |X| represents natural-join. 11. Based on the following tables answer the questions.
create table Books ( isbn char(20) primary key, bname char(50), type ENUM('technical', 'fiction', 'self-help') ); create table Authors ( idn char(9), isbn char(20), primary key (idn, isbn) );

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'; select idn from Authors where not exists (select * from Authors A, Books B where A.isbn=B.isbn and B.type='fiction') select idn from Authors where idn not in (select idn from Authors A, Books B where A.isbn=B.isbn and B.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: employee(employee_name, street, city) works(employee_name, company_name, salary) company(company_name, city) manages(employee_name, manager_name) 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';

2. employee-name, city (employee |X| ( company-name = "First Bank Corporation"(works)))


select e.employee_name, city from employee e, works w where w.company_name = 'First Bank Corporation' and w.employee_name = e.employee_name

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)
select * from employee where employee name in (select employee_name from works where company name = 'First Bank Corporation' and salary > 10000)

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. employee-name( company-name "First Bank Corporation"(works))
select employee_name from works where company_name <> 'First Bank Corporation'

If people may work for several (0 or more) companies: employee-name(employee) - employee-name( company-name = "First Bank Corporatoin")(works))
select employee name from employee where employee name not in (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. employee-name(works) - ( works.employee-name ( works |X| (works.salary works2.salary works2.company-name = "Small Bank Corporation") works2(works)))
select employee name from works where salary > all (select salary from works where company name = '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. Note: Small Bank Corporation will be included in each answer. company-name(company (&pi city( company-name = "Small Bank Corporation" (company))))
select S.company name from company S where not exists ((select city from company where company name = 'Small Bank Corporation') except (select city from company T where S.company name = T.company name))

7. employee-name(employee |X| works |X| company)


select employee_name from employee natural join works natural join company

8. employee-name((employee |X| manages) |X| (manager-name = employee2.employee-name employee.street = employee2.street employee.city = employee2.city)( employee2(employee)))
select employee_name from employee natural join manages natural join (select * from employee e1, employee e2 where manager_name = e2.employee_name and e1.street = e2.street and e1.city = e2.cit

15. Consider the following relational database: employee(employee_name, street, city) works(employee_name, company_name, salary) company(company_name, city) manages(employee_name, manager_name) 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)) create table works ( employee_name char(20), company_name char(15), salary integer, primary key (person name), foreign key (person name) references employee, foreign key (company name) references company) create table company ( company_name char(15), city char(30), primary key (company name)) create table manages ( employee_name char(20), manager name char(20), primary key (person name), foreign key (person name) references employee, foreign key (manager name) references employee)

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))

2. check(salary < all (select manager_salary from


(select manager_name, manages.employee_name as emp_name, salary as manager salary from works, manages where works.employee_name = manages.manager_name) where employee_name = emp_name))

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...

member_no name address phone email borrow isbn member_no checkout_date borrow_period book isbn book_title authors 17. 1. Explain the four constraints on specialization and generalization. 2. What is difference between a shared class and a category? Ans: 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...

Student_ID &rarr Student_Name, Campus_Address, Major Course_ID &rarr Course_Title, Instructor_Name, Instructor_Location {Student_ID, Course_ID} &rarr Grade Instructor_Name &rarr Instructor_Location Campus_ Instructor_ Instructor_ Student_ID Student_Name Major Course_ID Course_Title Grade Addresss Name Location 208 168300458 Williams IS IS 350 Database Codd B 104 A Brooks 268300458 Smith 543291073 Baker 403 Brooks IS IS 465 Systems Analysis Parsons B 317 B C B A

104 Acctg IS 350 Database Codd B 104 Phillips 104 543291073 Baker Acctg Acct 201 Fund Acctg Miller H310 Phillips 104 543291073 Baker Acctg Mktg 300 Intro Mktg Bennett B 212 Phillips 1. Draw the functional dependency diagram. 2. Which normalization form of the relation belongs to? 3. Normalize the following tables of data to 3 NF and draw the relation schema diagram. Ans: 1.

2. It is 1NF because there are two keys to determine other attributes. 3.

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...

20.

1. Describe the XML syntax rules. 2. What is a well formed XML document? Ans: 1.

1. All XML documents must have a root tag. 2. All XML elements must have a closing tag. 3. All XML elements must be properly nested. 4. XML tags are case sensitive. 5. Attribute values must always be quoted. 6. Element names must follow naming rules. 2. An XML document that strictly adheres to XML syntax rules. 21. What are the four possible keywords in a DTD declaration? What are they for? Ans: ELEMENT is used to define tags. ATTLIST is used to define tag attributes. ENTITY is used to define entities. NOTATION is used to define data type notations. 22. What are the four possible default values for an attribute declaration in a DTD? Ans: A value specifies the value. A #FIXED value specifies the value, which every element will have and which cannot be changed. #REQUIRED specifies every instance of the element must specify a value. #IMPLIED indicates no default values.

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 <!ELEMENT <!ELEMENT <!ELEMENT <!ELEMENT ]> concerts (concert)> cconcert (performer, place, date)> performer (#PCDATA)> place (#PCDATA)> date (#PCDATA)>

3. <?xml version="1.0" ?>


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:complexType name="concerts" minOccurs="1" maxOccurs="unbounded" /> <xsd:sequence> <xsd:complexType name="concert"> <xsd:sequence> <xsd:element name="performer" type="xsd:string" /> <xsd:element name="place" type="xsd:string" /> <xsd:element name="date" type="xsd:date" /> </xsd:sequence> </xsd:complexType> </xsd:sequence> </xsd:complexType> </xsd:schema>

4. <?xml version="1.0" ?>


<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

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

S-ar putea să vă placă și