Relational algebra and Alpha language exercise p75
Supplier number of J1 parts for supply engineering sno
Supply Engineering J1 Part P1 supplier number
Supply Engineering J1 Part red supplier number SNO
No use of the Tianjin supplier of red parts produced by the project number Jno;
To use at least the supplier S1 all parts supplied by the project number Jno;
Please advise, do not know the right to do, welcome to contact [email protected]
Because relational algebra-to-SQL statements feel that there is no alpha-language-to-SQL easy, only the alpha-language answer is written.
Alpha Language Exercise P75
There is a SPJ database, including S,P,J,SPJ four relationship modes:
Supplier S (SNO, SNAME, STATUS, city)
Part P (PNO, PNAME, COLOR, WEIGHT)
Engineering J (Jno, Jname, city)
Availability Table SPJ (SNO, PNO, Jno, QTY)
Supplier number of J1 parts for supply engineering sno
GET W (spj.sno): Spj.jno = "J1";
Supply Engineering J1 Part P1 supplier number
GET W (spj.sno): Spj.jno = "J1" ^ spj.pno= "P1";
Supply Engineering J1 Part red supplier number SNO
Range P px
GET W (Spj.sno): Present px (Spj.jno = px.jno ^ Px.color = "Red");
No use of the Tianjin supplier of red parts produced by the project number Jno;
Range S sx,p PX,SPJ SPJX
GET W (Spj.jno): Spjx not present (Spjx.sno = sx.sno ^ sx.city = "Tianjin" ^ spjx.pno = p.pno ^ P.color = "Red");
Range S sx,p PX,SPJ SPJX
GET W (spj.x): All SPJX (spjx.sno! = Sx.sno ^ sx.city = "Tianjin" or spjx.pno! = p.pno ^ P.color = "Red");
Will miss out on a project that is not available for the time being.
Range S sx,p PX,SPJ SPJX
GET W (J.jno): Spjx not present (Spjx.sno = sx.sno ^ sx.city = "Tianjin" ^ spjx.pno = p.pno ^ P.color = "Red");
Range S sx,p PX,SPJ SPJX
GET W (J.jno): All SPJX (spjx.sno! = Sx.sno ^ sx.city = "Tianjin" or spjx.pno! = p.pno ^ P.color = "Red");
To use at least the supplier S1 all parts supplied by the project number Jno;
Idea: Check each part of p in turn to see if the S1 supply the part. If S1 supplies this part, see if the part is used in a project. If a project
With all the parts supplied by the S1, the project can be put into the result set.
Table involved in expression: J
Table of operating conditions involved: SPJ,SPJ
Range SPJ SPJX,SPJ spjy,p px
GET W (J.jno): All PX (
Existence of SPJX (spjx.pno=px.pno ^ Spjx.sno = "S1") = Presence Spjy (spjy.pno = px.pno ^ Spjy.jno = j.jno)
)
From for notes (Wiz)
Database System Introduction Book after exercise answer 4th edition Second Chapter