cd ~
mkdir csc6341
pwd
cp /shared/csc6341/spj.sql ~/csc6341
mysql ZHANG -u yzhang -p < spj.sql
mysql> select user(); +------------------+ | user() | +------------------+ | yzhang@localhost | +------------------+ 1 row in set (0.00 sec) mysql> select database(); +------------+ | database() | +------------+ | ZHANG | +------------+ 1 row in set (0.00 sec) mysql> select now(); +---------------------+ | now() | +---------------------+ | 2019-09-04 23:56:39 | +---------------------+ 1 row in set (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | ZHANG | +--------------------+ 2 rows in set (0.00 sec) mysql> show tables; +-----------------+ | Tables_in_ZHANG | +-----------------+ | cellar | | j | | p | | s | | spj | +-----------------+ 5 rows in set (0.00 sec)
Question 4.1. Once you complete the above steps, you basically finished this question. Just make sure the tables have been created and data was populated (inserted) appropriately.
Question 4.4 (b). Each triple such as | S2 | P3 | J1 | 400 | in table spj is a shipment. Interpret as supplier S2 provides part P3 for project J1 with a quantity of 400. There are seven projects (J1 through J7) in table j in total. All of them appear in the shipments table spj, that is, every project is involved in some shipment(s). Since you need to write a query to delete those projects from table j which don't have any shipments (that is, there are no entries in spj table for those projects), you might need to insert a couple of new projects (e.g. J8 and J9) into table j so they don't have any shipments. Then see if your query can delete those two projects from table j. Otherwise your query won't delete any projects even if it is correctly written. A sample query is below: The query should involve two tables, j and spj through join or subquery.
Find all the projects that use P2 parts: select * from j where j_num in (select j_num from spj where p_num = 'P2'); +-------+---------+--------+ | J_NUM | JNAME | CITY | +-------+---------+--------+ | J2 | Display | Rome | | J4 | Console | Athens | +-------+---------+--------+
((S JOIN SPJ) WHERE P# = P#('P2')){S#, CITY}
CREATE VIEW V AS
((S JOIN SPJ) WHERE P# = P#('P2')){S#, CITY}
(V WHERE CITY = 'London'){S#}
What does this query do? What is the predicate for the result of the query?