Question: Can someone please help fix this! I will attach the notes I was given, I was told my lab was not fully correct and now
Can someone please help fix this! I will attach the notes I was given, I was told my lab was not fully correct and now I am wondering how it could be fixed.
Based on the Premiere Database.
In each case, indicate how you could use the relational algebra to obtain the desired results.
SLSREP (SLSRNUMB, SLSRNAME, SLSRADDR, TOTCOMM, COMMRATE)
CUSTOMER (CUSTNUMB, NAME, ADDRESS, BALANCE, CREDLIM, SLSRNUMB)
FK SLSRNUMB -> SLSREP
ORDER (ORDNUMB, DATE, CUSTNUMB)
FK CUSTNUMB -> CUSTOMER
ORDLNE (ORDNUMB, PARTNUMB, NUMORD, QUOTPRCE)
FK ORDNUMB -> ORDER
FK PARTNUMB -> PART
PART (PARTNUMB, PARTDESC, UNONHAND, ITEMCLSS, WREHSENM, UNITPRCE)
Q1: List the number and name of all sales reps.
PROJECT [SLSREP] OVER [SLSRNUMB], [SLSRNAME]
GIVING [Answer]
Q2: List all the information from the part table concerning part BT04.
SELECT [PART] WHERE [PARNUMB] = BT04
GIVING [Answer]
Q3: List the order number, order date, customer number, last name, and first name from each order.
JOIN [CUSTOMER] [ORDER] WHERE [CUSTOMER] . [CUSTNUMB]
= [ORDER] . [CUSTNUMB]
GIVING [Answer]
PROJECT [Temp] OVER ([ORDNUMB], [DATE], [CUSTNUMB], [NAME])
GIVING [Answer]
Q4: List the order number, order date, customer number, and customer name for each order placed by any customer represented by the sales rep whose last name is Jones.
JOIN [SLSREP] [CUSTOMER]
WHERE [SLSREP] . [SLSRNUMB] = [CUSTOMER] . [SLSRNUMB]
GIVING (temp 1)
JOIN [temp 1], [ORDER]
WHERE [temp 1] [CUSTNUMB] = [ORDER] . [CUSTNUMB]
GIVING (temp 2)
SELECT (temp 2)
WHERE [NAME] = Jones
GIVING (temp 3)
PROJECT (temp 3) OVER [ORDNUMB], [DATE], [CUSTNUMB], [NAME]
GIVING [Answer]
Q5: List the number and date of all orders that were either placed on 9/02/2001 or placed by a customer with a $1000 credit limit. (UNION)
JOIN [ ORDER], [CUSTOMER]
WHERE [ORDER] . [CUSTNUMB] = [CUSTOMER] . [CUSTNUMB]
GIVING (temp 1)
SELECT (temp 1)
WHERE [DATE] = 9/02/2001
UNION [CREDLIM] = $1000
GIVING (temp 2)
PROJECT (temp 2) OVER [ORDNUMB], [DATE]
GIVING [Answer]
Q6: List the number and date of all orders that were placed on 9/02/2001 by a customer with a $1000 credit limit. (INTERSECT)
JOIN [ ORDER], [CUSTOMER]
WHERE [ORDER] . [CUSTNUMB] = [CUSTOMER] . [CUSTNUMB]
GIVING (temp 1)
SELECT (temp 1)
WHERE [DATE] = 9/02/2001
INTERSECT [CREDLIM] = $1000
GIVING (temp 2)
PROJECT (temp 2) OVER [ORDNUMB], [DATE]
GIVING [Answer]
Q7: List the number and date of all orders that were placed on 9/02/2001 but not by a customer with a $1000 credit limit. (DIFFERENCE)
JOIN [ ORDER], [CUSTOMER]
WHERE [ORDER] . [CUSTNUMB] = [CUSTOMER] . [CUSTNUMB]
GIVING (temp 1)
SELECT (temp 1)
WHERE [DATE] = 9/02/2001
DIFFERENCE [CREDLIM] = $1000
GIVING (temp 2)
PROJECT (temp 2) OVER [ORDNUMB], [DATE]
GIVING [Answer]
These are the notes we had:


Relational Algebra: theoretical way of manipulating a relational daturuos. The 8 relational functions: SELECT - retrieves certain rows from an existing table and saves them as a new table. Example - SELECT List those customers who are represented by salesrep 12. SELECT (customer) WHERE [slsrep\#] 12 GIVING (answer) PROJECT - causes only certain columns to be included. Example - PROJECT List the number, name of those customers PROJECT (customer) OVER [cust\#],[name] GIVING (answer) UNION - all rows that is either in 1st table OR 2nd table OR both. INTERSECT - rows common to both 1st table AND 2nd table. DIFFERENCE - A minus B is the set of all rows that are in 1st table (A) but NOT in 2nd table (B). Example - UNION List the number, name of those customers who either have orders OR are represented by salesrep 12 OR both. JOIN (order), (customer) WHERE [customer].[cust\#]=[order].[cust\#] GIVING (temp1) PROJECT (temp1) OVER [cust\#],[name] GIVING (temp2) SELECT (customer) WHERE [slsrep\#]=12 GIVING (temp3) PROJECT (temp3) OVER [cust\#],[name] GIVING (temp4) UNION (temp2) WITH (temp4) } GIVING (answer) Example - Intercept List the number, name of those customers who have orders AND are represented by salesrep 12. INTERSECT (temp2) WITH (temp4) GIVING (answer) Example - Difference List the number, name of those.customers who have orders but are NOT represented by salesrep 12 . SUBTRACT (temp4) FROM (temp2) GIVING (answer) PRODUCT - is the table obtain by concatenating every row in 1st table with every row in the 2nd table. Eg. Table 1 has M rows Table 2 has N rows Final Table has MN rows DIVIDE - the column from the 1st table that is NOT in the 2nd table
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
