Database System Introduction Book after exercise answer 4th edition Second Chapter

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.