Question

Relational Algebra (50 pts): Consider the following database schema that keeps track of Sailors, Boats and...

Relational Algebra (50 pts): Consider the following database schema that keeps track of Sailors, Boats and the boats reserved by sailors.

Sailors(sid, sname, rating, age) Boatsbid, bname, color) Reserves(sid, bid, date) Keys are underlined in each relation.

Specify the following queries in Relational Algebra using above database schema.

(f) find the name of sailors with the highest rating

(g) find the name and age of oldest sailors

(h) find the age of youngest sailor for each rating level

(i) find the names of sailors who reserved more red boats than green

(j find names of sailors who have reserved all the boats

Homework Answers

Answer #1

To reduce the issues of typing let us consider:

Sailors database as "s", Boats as "b", and Reserves as "r".

f)

Question statement-

Πsname(s)- Πs2.sname(σs2.rating<s.rating[ρs2(s)*(s])

Answer-

Ans(S) <- s(S, _, _, _), ¬ bad(S).

Bad(S) <- s(S, _, R, _), s(_, _, R’, _), R<R’.

g)

Question statement-

πsname,age([πsid(s)-πs2.sid(σs2.age<s.age(ρs2(s)*s))] s)

Answer-

ans(N,A) <- s(S, N, _, A), ­­­­ ¬ bad(S).

bad(S) <- s(S, _, _, A), s(_, _, _, A’), A<A’.

h)

SELECT S.rating, MIN(S.age)

FROM SAILOR S

GROUP BY S.rating

j)

Question statement-

πsname([πsid,bid(r) / πbid(b)] s).

Answer-

ans(N) <- s(S, N, _, _), ¬ bad(S).

bad(S) <- s(S, _, _, _), b(B, _, _), ¬ res(S, B).

res(S,B) <- r(S,B,_).

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Specify this query in Relational Algebra using the given database schema: Find the sid's of sailors...
Specify this query in Relational Algebra using the given database schema: Find the sid's of sailors who made at least 3 reservations. Saliors(sid, sname, rating, age) Boats (bid, name,color) Reserves(sid, bid, date) Is this correct: ∏sname((OCOUNT(sid)>=3Reserves))⋈Sailors)
Consider the following relational schema about a University (the primary keys are underlined and foreign keys...
Consider the following relational schema about a University (the primary keys are underlined and foreign keys are italic) STUDENT(StudentID, name, major, year, age) CLASS(ClassName, meetsAt, room, LecturerID) ENROLLED(StudentID, ClassName, mark) LECTURER(LecturerID, name, DepartmentID) DEPARTMENT(DepartmentID, name) Write the SQL statements for the following query: B1. Find the age of the oldest student. B2. Find the ID’s of lecturers whose name begins with “K” B3. Find the age of the youngest student who is enrolled in Mechatronics. B4. Find the age of...
Given the following schema: Catalog(sid, pid, price) (Line under sid and pid) Suppliers(sid, sname, phonenum) (Line...
Given the following schema: Catalog(sid, pid, price) (Line under sid and pid) Suppliers(sid, sname, phonenum) (Line under sid) Parts(pid, pname, color) (Line under pid) Write the following queries in Relational Algebra: “Find names of suppliers who supply a blue part that costs less than 120 dollars and a yellow part that costs more than 150 dollars
1. In SQL. Given the following relational database schema . The primary key is underlined. All...
1. In SQL. Given the following relational database schema . The primary key is underlined. All attributes are of type string if not indicated otherwise.  branch(branch_name,branch_city,assets: integer)  customer(customer_i,customer_name,customer_street,customer_city)  account(account_number,branch_name,balance)  depositor(customer_id,account_number) a. Find the names of customers that have accounts in every branch in Miami. b. Find the names of customers who do not have an account. (assume the bank keeps the customer information even if the account is closed.)
Consider the following database schema used to track blood donations. The database has been in use...
Consider the following database schema used to track blood donations. The database has been in use for several years and contains thousands of entries. Primary keys are Bolded and foreign keys carry the same names as the primary keys they reference Receptionist(RID, Name, Address, Phone#) Donor (Name, Address, Phone#, SSN, Gender, DOB) Blood(BID, Blood_type, Cost, Name, Phone#, NID) Nurses(NID, Name, Address, Phone#) Transfusions(PatientID, Date, Trans#, BID) Question: Since donors may donate every 60 days, a collection date needs to be...
Consider the following relational schema (the primary keys are underlined and foreign keys are italic) ITEM(ItemName,...
Consider the following relational schema (the primary keys are underlined and foreign keys are italic) ITEM(ItemName, ItemType, ItemColour) DEPARTMENT(Deptname, DeptFloor, DeptPhone, Manager) EMPLOYEE(EmpNo, EmpFname, EmpSalary, DeptName, SupervisedBy) SUPPLIER(SupNo, SupName) SALE(SaleNo, SaleQty, ItemName, DeptName) DELIVERY(DeliNo, DeliQty, ItemName, DeptName, SupNo) Write the SQL statements for the following queries: C1. Find the names of items sold on first and second floors. [1 mark] C2. For each department, list the department name and average salary of the employees where the average salary of the...
The following is about databases: queries on relational algebra Consider the following schemas for a LinkedIn-like...
The following is about databases: queries on relational algebra Consider the following schemas for a LinkedIn-like professional network. Note this is a slightly simplified version from your last assignment. Assume that the connections are mutual. Person (PID, first_name, last_name, age, gender) School (school_ID, school_name, type, city, state) Education (PID, school_ID, degree, major, year) Company (company_ID, company_name, total_asset, headquarter) Branch (company_ID, branch_num, city, state) WorksAt (PID, company_ID, branch_num, start, end) Connection (PID, friend_ID) For each relation, the attribute(s) of the primary...
The following is about databases: queries on relational algebra Consider the following schemas for a LinkedIn-like...
The following is about databases: queries on relational algebra Consider the following schemas for a LinkedIn-like professional network. Note this is a slightly simplified version from your last assignment. Assume that the connections are mutual. Person (PID, first_name, last_name, age, gender) School (school_ID, school_name, type, city, state) Education (PID, school_ID, degree, major, year) Company (company_ID, company_name, total_asset, headquarter) Branch (company_ID, branch_num, city, state) WorksAt (PID, company_ID, branch_num, start, end) Connection (PID, friend_ID) For each relation, the attribute(s) of the primary...
1. Consider the following tables in a relational database. Provide the appropriate "SELECT" SQL statement necessary...
1. Consider the following tables in a relational database. Provide the appropriate "SELECT" SQL statement necessary to answer the queries that follow. Primary keys are underlined and foreign key fields have an asterisk at the end of the field. CUSTOMERS (CUST-NO, C-NAME, C-ADDRESS, BALANCE) SALESPERSONS (SP-NO, S-NAME, DATE-EMPLOYED, SALARY) SALES (INVOICE-NO, DATE, CUST-NO*, SP-NO*) a) List the salesperson name and salary for all sales to customers whose balance outstanding is greater than 20000. b) List the names and addresses of...
Consider the following schema: Distributor (d-id: numeric, d-name: varchar, address: varchar) Item (i-id: numeric, i-name: varchar,...
Consider the following schema: Distributor (d-id: numeric, d-name: varchar, address: varchar) Item (i-id: numeric, i-name: varchar, color: varchar) Inventory (d-id: numeric, i-id: numeric, cost: numeric, instock: numeric) Where d-id is the distributor's id (primary key in Distributor), i-id is the item's id (primary key in Item), and d-id together with i-id is the primary key of Inventory. The Inventory relation lists the prices charged for items by distributors. Write the following queries using relational algebra: 1. Find the names of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT