40 likes | 144 Views
Schema BankWorld Customer( C_Name , C_Street, C_City) Depositor( Account_# , C_Name) Loan( Loan_# , B_Name, Amount) Borrower( C_Name , Loan_# ). Exercise: Select tuples of the loan relation where the branch name is “UTD” Find all tuples in which the amount of lent is more than $1200
E N D
Schema BankWorld • Customer(C_Name, C_Street, C_City) • Depositor(Account_#, C_Name) • Loan(Loan_#, B_Name, Amount) • Borrower(C_Name, Loan_#)
Exercise: • Select tuples of the loan relation where the branch name is “UTD” • Find all tuples in which the amount of lent is more than $1200 • Find those tuples pertaining to loans of more than $1200 made by “UTD” branch • List all loan numbers and the amount of loan • Find the names of all customers who live in “Dallas” • Find the names of all bank customers who have either an account or a loan or both • Find the name of all customers of the bank who have an account but not a loan • Find the name of all customers who have both a loan and an account
Express the following query using SQL: 1.Sailors X Reserves 2.Sailors sailors.id < reserves.id Reserves 3.Sailors sailors.id = reserves.id Reserves 4.Sailors Reserves 5.Find the names of sailors who have reserved boat 103 6.Find the names of sailors who have reserved a red boat 7.Find the colors of boats reserved by Dustin 8.Find the names of sailors who have reserved at least one boat 9.Find the names of sailors who have reserved a red or a green boat 10.Find the names of sailors who have reserved both a red and a green boat 11.Find the names of sailors with age over 20 who have not reserved a red boat 12.Find the names of sailors who have reserved at least two boats 13.Find the sids of all sailors who have reserved red boats but not green boats 14.Find sailors whose rating is better than some sailor called Smith 15.Find sailors whose rating is better than every sailor called Smith 16.Find the names of sailors who have not reserved a red boat 17.Find the average age of all sailors 18.Find the average age of sailors with a rating of 10 19.Find the name and age of the oldest sailor 20.Count the # of sailors 21.Find the names of sailors who are older than the oldest sailor with a rating 10 22.Find the age of the youngest sailor for each rating level 23.Find the age of the youngest sailor who is eligible to vote ( i.e., at least 18 years old) for each rating level with at least two such sailors 24.For each red boat, find the number of reservations for this boat 25.Find the average age of sailors for each rating level that has at least two sailors Find the average age of sailors who are of voting age (i.e., at least 18 years old) for each rating level that has at least two sailors