4
ADDITIONAL EXERCISES FOR DATABASE SQL 1. Answer the following questions in text book: 6.7, 6.8, 6.9, 6.10, 6.11 6.12, 6.13, 6.14, 6.15 6.22, 6.23, 6.28 2. Answer below questions based on schema in the exercises at the end of chapter 5. List all borrower details. List all book titles published in the year 2012. List all copies of book titles that are available for borrowing. List all copies of the book title “Lord of the Rings” that are available for borrowing. List the names of borrowers who currently have the book title “Lord of the Rings” on loan. List the names of borrowers with overdue books. How many copies of ISBN “0-321-52306-7” are there? How many copies of ISBN “0-321-52306-7” are currently available? How many times has the book with ISBN “0-321-52306-7” been borrowed? Produce a report of book titles that have been borrowed by “Peter Bloomfield”.

ADDITIONAL EXERCISES FOR DATABASE SQL - …author.uthm.edu.my/uthm/www/content/lessons/3005... · ADDITIONAL EXERCISES FOR DATABASE SQL ... type of dependency that exists between

Embed Size (px)

Citation preview

Page 1: ADDITIONAL EXERCISES FOR DATABASE SQL - …author.uthm.edu.my/uthm/www/content/lessons/3005... · ADDITIONAL EXERCISES FOR DATABASE SQL ... type of dependency that exists between

ADDITIONAL EXERCISES FOR DATABASE SQL 1. Answer the following questions in text book:

6.7, 6.8, 6.9, 6.10, 6.11 6.12, 6.13, 6.14, 6.15 6.22, 6.23, 6.28

2. Answer below questions based on schema in the exercises at the end of chapter 5.

List all borrower details. List all book titles published in the year 2012. List all copies of book titles that are available for borrowing. List all copies of the book title “Lord of the Rings” that are available for borrowing. List the names of borrowers who currently have the book title “Lord of the Rings” on

loan. List the names of borrowers with overdue books. How many copies of ISBN “0-321-52306-7” are there? How many copies of ISBN “0-321-52306-7” are currently available? How many times has the book with ISBN “0-321-52306-7” been borrowed? Produce a report of book titles that have been borrowed by “Peter Bloomfield”.

Page 2: ADDITIONAL EXERCISES FOR DATABASE SQL - …author.uthm.edu.my/uthm/www/content/lessons/3005... · ADDITIONAL EXERCISES FOR DATABASE SQL ... type of dependency that exists between

Entity Relationship Diagram 1. Use the following business rules to create a Crow’s Foot ERD. Write all appropriate

connectivities and cardinalities in the ERD. a. A department employs many employees, but each employee is employed by one

department. b. Some employees, known as “rovers,” are not assigned to any department. c. A division operates many departments, but each department is operated by one division. d. An employee may be assigned many projects, and a project may have many employees

assigned to it. e. A project must have at least one employee assigned to it. f. One of the employees manages each department, and each department is managed by only

one employee. g. One of the employees runs each division, and each division is run by only one employee.

2. The Jonesburgh County Basketball Conference (JCBC) is an amateur basketball association.

Each city in the county has one team as its representative. Each team has a maximum of 12 players and a minimum of 9 players. Each team also has up to three coaches (offensive, defensive, and physical training coaches). During the season, each team plays two games (home and visitor) against each of the other teams. Given those conditions, do the following: a. Identify the connectivity of each relationship. b. Identify the type of dependency that exists between CITY and TEAM. c. Identify the cardinality between teams and players and between teams and city. d. Identify the dependency between coach and team and between team and player. e. Draw the Chen and Crow’s Foot ERDs to represent the JCBC database.

3. Create an ERD based on the Crow’s Foot model, using the following requirements:

An INVOICE is written by a SALESREP. Each sales representative can write many invoices, but each invoice is written by a single sales representative.

The INVOICE is written for a single CUSTOMER. However, each customer can have many invoices.

An INVOICE can include many detail lines (LINE), each of which describes one product bought by the customer.

The product information is stored in a PRODUCT entity. The product’s vendor information is found in a VENDOR entity.

Page 3: ADDITIONAL EXERCISES FOR DATABASE SQL - …author.uthm.edu.my/uthm/www/content/lessons/3005... · ADDITIONAL EXERCISES FOR DATABASE SQL ... type of dependency that exists between

Normalization 1. 2. Using the description of the attributes given in below figure, convert the ERD shown into a dependency diagram and at least 3NF table.

(a) Identify the dependencies (b) Create table showing at least 3NF

Page 4: ADDITIONAL EXERCISES FOR DATABASE SQL - …author.uthm.edu.my/uthm/www/content/lessons/3005... · ADDITIONAL EXERCISES FOR DATABASE SQL ... type of dependency that exists between

4. Using the Invoice table structure below: (a) Write the relational schema, draw its dependency diagram and identify all

dependencies, including all partial and transitive dependencies. You can assume that the table does not contain repeating groups and that any invoice number may reference more than one product. (Hint: This table uses a composite primary key.)

(b) Normalize it to 2NF and 3NF