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
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...
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...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode)...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(fieldnum, id, title) INTEREST(fieldnum*, acnum*, descrip) Some notes on the Academics database: An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR). A research field...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT