0% found this document useful (0 votes)
2 views

Lab1

The document contains a series of database queries related to employees, branches, customers, and accounts. Each question specifies different criteria for selecting and joining data from the Employees, Branches, Customers, and Accounts tables. The queries utilize operations such as selection, projection, and intersection to retrieve specific information based on conditions like dates and customer types.

Uploaded by

caoducanh1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab1

The document contains a series of database queries related to employees, branches, customers, and accounts. Each question specifies different criteria for selecting and joining data from the Employees, Branches, Customers, and Accounts tables. The queries utilize operations such as selection, projection, and intersection to retrieve specific information based on conditions like dates and customer types.

Uploaded by

caoducanh1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Question a:

π_Emp_ID, First_Name, Last_Name, Start_date(σ_Start_date >= '2000-01-01' AND Start_date <= '2001-
12-31' (σ_Branch_ID = 1 (Employees)))
Question b:
π_Emp_ID, (First_Name || ' ' || Last_Name) AS Emp_FullName, Start_Date, BranchName (
σ_Title = 'Teller' (Employees) ⨝ Branch_ID σ_BranchName = 'Woburn branch' (Branches)
)
Question c:

π_Branch_ID, BranchName (
Branches - π_Branch_ID, BranchName (
σ_Start_date >= '2001-01-01' AND Start_date <= '2001-12-31' (
Employees ⨝ (Employees.Branch_ID = Branches.Branch_ID) Branches
)
)
)
Question d:

π_Branch_ID, BranchName, City (


(π_Branch_ID, BranchName, City (
σ_CUST_TYPE_CD = 'I' (
Customers ⨝ (Customers.CUST_ID = Accounts.CUST_ID) ⨝ (Accounts.Open_Branch_ID =
Branches.Branch_ID) Branches
)
)) ∩
(π_Branch_ID, BranchName, City (
σ_CUST_TYPE_CD = 'B' (
Customers ⨝ (Customers.CUST_ID = Accounts.CUST_ID) ⨝ (Accounts.Open_Branch_ID =
Branches.Branch_ID) Branches
)
))
)
Question e:

π_CUST_ID, ADDRESS, CITY (


σ_Open_Date >= '2000-01-01' AND Open_Date <= '2000-12-31' (
π_CUST_ID, COUNT(Account_ID) >= 2 (
Accounts ⨝ (Accounts.CUST_ID = Customers.CUST_ID) Customers
)
)
)
Question f:

π_Emp_ID, (First_Name || ' ' || Last_Name) AS EmpFullName, BranchName (


π_Emp_ID, (First_Name || ' ' || Last_Name) AS EmpFullName, BranchName (
σ_CustomerCount >= 3 (
Employee_Customers ⨝ (Employee_Customers.CUST_ID = Accounts.CUST_ID) ⨝
(Accounts.Open_Emp_ID = Employees.Emp_ID) ⨝ (Employees.Branch_ID = Branches.Branch_ID) Branches
)
)
)
Question g:

π_Account_ID, Balance, Open_Date (


(Accounts ⨝ (Accounts.Balance IN (
π_Balance (
σ_Balance <= (
SELECT MAX(Balance) FROM Accounts
)(
Accounts
)
)
)))
) LIMIT 2

You might also like