# 数据库原理 Exercises 3&4&5

Database System Concepts Exercises of Chapter 5&6&8

# Database System Concepts Exercises of Chapter 5&6

Exercise 5.8 Consider the bank database of Figure 5.25. Write an sQL trigger to carryout the following action: On delete of an account, for each owner of theaccount, check if the owner has any remaining accounts, and if she doesnot, delete her from the depositor relation.

branch(branch_name, branch_city, assets)

customer ( customer_name, customer_street, customer_city )

loan( loan_number, branch_name, amount)

borrower ( customer_name, loan_number )

account ( account_number, branch_name, balance )

depositor ( customer_name, account_number )

Figure 5.25

My answer:

Exercise 5.15 Consider an employee database with two relations employee ($\underline{employee\_name}$, street, city) works ($\underline{employee\_name}$, company_name, salary) where the primary keys are underlined. Write a query to find companies whose employees earn a higher salary, on average, than the average salary at "First Bank Corporation". a. Using SQL functions as appropriate. b. Without using SQL functions.

My answer:

Exercise 6.1 Write the following queries in relational algebra, using the university schema. a. Find the titles of courses in the Comp. Sci. department that have 3 credits. b. Find the IDs of all students who were taught by an instructor named Einstein; make sure there are no duplicates in the result. c. Find the highest salary of any instructor. d. Find all instructors earning the highest salary (there may be more than one with the same salary).

My answer:

http://enderfga.cn/2022/04/29/data3/

Enderfga

2022年4月29日