¹Øϵ΢»ý·ÖÊÇÒ»ÖÖÂß¼·ûºÅ£¬ÆäÖеIJéѯÊÇͨ¹ý¹«Ê½±íʾ´ð°¸ÀïµÄ¼Ç¼±ØÐëÂú×ãµÄijЩÂß¼Ô¼ÊøÀ´±íʾµÄ¡£
PROJECT £¨¦Ð£©£º´ÓÒ»¸ö¹ØϵÀïÃæ³éÈ¡Ö¸Ã÷µÄÊôÐÔ£¨ÁУ©¡£Áî R Ϊһ¸ö°üº¬Ò»¸öÊôÐÔ X µÄ¹Øϵ¡£¦ÐX(R) = {t(X) &mid t ¡ÊR}£¬ÕâÀï t(X) ±íʾ¼Ç¼ t ÀïµÄÊôÐÔ X µÄÖµ¡£
PRODUCT £¨¡Á£©£º¼ÆËãÁ½¸ö¹ØϵµÄµÑ¿¨¶ù³Ë»ý¡£ÁîR Ϊº¬ÓÐ k1 ¸öÔªµÄ±í¶øÁî S Ϊº¬ÓÐ k2 ¸öÔªµÄ±í¡£R ¡Á S ÊÇËùÓк¬ÓÐ k1 + k2 ¸öÔª¼Ç¼µÄ¼¯ºÏ£¬ÆäÇ°Ãæ k1 ¸öÔª¹¹³É R ÀïµÄÒ»Ìõ¼Ç¼¶øºóÃæ k2 ¸öÔª¹¹³É S ÀïµÄÒ»Ìõ¼Ç¼¡£
UNION £¨¡È£©£º¼ÆËãÁ½¸ö±íµÄ¼¯ºÏÀíÂÛÉϵÄÁªºÏ¡£¸ø³ö±í R ºÍ S £¨Á½ÕßÓÐÏàͬԪ/ÁÐÊý£©£¬ R ¡È S µÄÁªºÏ¾ÍÊÇËùÓÐÔÚ R ÀïÃæÓлò S ÀïÃæÓлòÔÚÁ½¸ö±íÀïÃ涼ÓеļǼµÄ¼¯ºÏ¡£
INTERSECT £¨¡É£©£º¼ÆËãÁ½¸ö±í¼¯ºÏÀíÂÛÉϵĽ»¼¯¡£¸ø³ö±í R ºÍ S£¬R ¡É S ÊÇͬʱÔÚ R ºÍ S ÀïÃæµÄ¼Ç¼µÄ¼¯ºÏ¡£ÎÒÃÇͬÑùÒªÇó R ºÍ S ÓµÓÐÏàͬµÄÔª/ÁÐÊý¡£
DIFFERENCE £¨- »ò &setmn£©£º¼ÆËãÁ½¸ö±íµÄÇø±ðµÄ¼¯ºÏ¡£Áî R ºÍ S »¹ÊÇÓµÓÐÏàͬԪ/ÁÐµÄ±í¡£R - S ÊÇÔÚ R ÀïÃ浫ÊDz»ÔÚ S ÀïÃæµÄ¼Ç¼µÄ¼¯ºÏ¡£
JOIN £¨¡Ç£©£ºÍ¨¹ý¹²Í¬ÊôÐÔÁª½ÓÁ½¸ö±í¡£Áî R Ϊһ¸öÓÐÊôÐÔ A£¬B
ºÍ C µÄ±í£¬¶øÁî S Ϊһ¸öÓÐÊôÐÔ C£¬D
ºÍ E µÄ±í¡£Á½¸ö±íÓÐÒ»¸ö¹²Í¬µÄÊôÐÔ£¬ÊôÐÔ C¡£R ¡Ç S = ¦ÐR.A,R.B,R.C,S.D,S.E£¨¦ÒR.C=S.C(R
¡Á S)£©¡£ÎÒÃÇÔÚÕâÀï¸ÉÁËÉçÄØÃÇ£¿Ê×ÏÈÎÒÃǼÆËãµÑ¿¨¶ù³Ë»ý R ¡Á S¡£È»ºóÎÒÃÇÑ¡ÔñÄÇЩ¹«¹²ÊôÐÔ
C
µÄÊýÖµÏàͬ(¦ÒR.C = S.C)µÄ×ֶΡ£ÕâʱÎÒÃÇÓµÓÐÒ»¸ö°üº¬ÊôÐÔ
C
Á½´ÎµÄ±í£¬È»ºóÎÒÃÇ°ÑÖظ´µÄÁÐÈ¥µôÒÔºóµÃ³öÎÒÃÇÒªµÄ½á¹û¡£
ÈÃÎÒÃÇ¿´¿´¼ÆËãÒ»¸öÁªºÏÐèÒªµÄ¸÷¸ö²½Öè²úÉúµÄ±í¡£¸ø³öÏÂÃæÁ½¸ö±í£º
R A | B | C S C | D | E ---+---+--- ---+---+--- 1 | 2 | 3 3 | a | b 4 | 5 | 6 6 | c | d 7 | 8 | 9
R x S A | B | R.C | S.C | D | E ---+---+-----+-----+---+--- 1 | 2 | 3 | 3 | a | b 1 | 2 | 3 | 6 | c | d 4 | 5 | 6 | 3 | a | b 4 | 5 | 6 | 6 | c | d 7 | 8 | 9 | 3 | a | b 7 | 8 | 9 | 6 | c | dÔÚÑ¡Ôñ ¦ÒR.C=S.C(R ¡Á S) ºóÎÒÃǵõ½£º
A | B | R.C | S.C | D | E ---+---+-----+-----+---+--- 1 | 2 | 3 | 3 | a | b 4 | 5 | 6 | 6 | c | dɾ³ýÖظ´µÄÁÐ S.C ÎÒÃÇÓÃÏÂÃæµÄ²Ù×÷£º¦ÐR.A,R.B,R.C,S.D,S.E(¦ÒR.C=S.C(R ¡Á S)) ½«ÆäÑ¡³ö£¬µÃµ½£º
A | B | C | D | E ---+---+---+---+--- 1 | 2 | 3 | a | b 4 | 5 | 6 | c | dDIVIDE £¨¡Â£©£ºÁî R ÊÇÒ»¸öÓÐÊôÐÔ A£¬B£¬C ºÍ D µÄ±í£¬²¢ÇÒÁî S ÊÇÒ»¸öÓÐ×ÅÊôÐÔ C ºÍ D µÄ±í¡£È»ºóÎÒÃǰѳý¶¨ÒåΪ£ºR ¡Â S = {t &mid &forall ts ¡Ê S &exist tr ¡Ê R Áî tr(A,B)=t¡Ätr(C,D)=ts} ÕâÀï tr(x,y) ´ú±í±í R ÀïÖ»°üº¬ÔªËØ x ºÍ y µÄ¼Ç¼¡£×¢Òâ¼Ç¼ t Ö»°üº¬¹Øϵ R ÀïµÄÔªËØ A ºÍ B¡£
¸ø³öÏÂÃæµÄ±í
R A | B | C | D S C | D ---+---+---+--- ---+--- a | b | c | d c | d a | b | e | f e | f b | c | e | f e | d | c | d e | d | e | f a | b | d | eR ¡Â S Éú³É
A | B ---+--- a | b e | d¹ØÓÚ¹Øϵ´úÊýµÄ¸üÏêϸµÄÃèÊöºÍ¶¨Ò壬Çë²Î¿¼[Ullman, 1988] »ò [Date, 1994]¡£
»ØÒäÒ»ÏÂÎÒÃDzûÃ÷µÄËùÓпÉÒÔÓÃÓï´ÓÊý¾Ý¿âÀï¼ìË÷Êý¾ÝµÄ¹Øϵ²Ù×÷·û¡£ÏÖÔÚÎÒÃÇ¿ÉÒԻص½Ç°Ò»ÕµÄÀý×ÓÀ¹ØϵÊý¾ÝÄ£ÐÍÀïµÄ²Ù×÷£©£¬ÄÇʱÎÒÃÇÐèÒªÖªµÀÏúÊÛ²¿¼þ Screw µÄËùÓй©Ó¦É̵ÄÃû³Æ¡£ÏÖÔÚÎÒÃÇ¿ÉÒÔÓÃÏÂÃæµÄ¹Øϵ´úÊýµÄ²Ù×÷»Ø´ðÕâ¸öÎÊÌâÁË£º
¦ÐSUPPLIER.SNAME(¦ÒPART.PNAME='Screw'(SUPPLIER ¡Á SELLS ¡Á PART))ÎÒÃdzÆÕâÑùµÄ²Ù×÷ÊÇÒ»´Î²éѯ¡£Èç¹ûÎÒÃǶÔÎÒÃǵÄÀý×Ó±í£¨The Suppliers and Parts Database£©½øÐÐÉÏÊö²éѯ¼ÆË㣬ÎÒÃǽ«»ñµÃÏÂÃæ½á¹û£º
SNAME ------- Smith Adams
¼Ç¼¹Øϵ΢»ý·Ö£¨Tuple Relational Calculus£©£¨TRC£©£¬Æä±äÁ¿´ú±í¼Ç¼¡£
Èç¹ûÎÒÃÇÏëÓà TRC »Ø´ðÀý×Ó Ò»¸öʹÓùØϵ´úÊýµÄ²éѯ ÀïµÄÎÊÌ⣬ÎÒÃÇ¿ÉÒÔд³öÏÂÃæ²éѯ£º
{x(SNAME) &mid x ¡Ê SUPPLIER ¡Ä \nonumber &exist y ¡Ê SELLS &exist z ¡Ê PART (y(SNO)=x(SNO) ¡Ä \nonumber z(PNO)=y(PNO) ¡Ä \nonumber z(PNAME)='Screw')} \nonumber¶Ô ¹©Ó¦É̺Ͳ¿¼þÊý¾Ý¿â ¼ÆËãÕâ¸ö²éѯͬÑùµÃ³öÓë Ò»¸öʹÓùØϵ´úÊýµÄ²éѯÏàͬµÄ½á¹û¡£
ÓÐʱºòÎÒÃÇ˵»ùÓÚ¹Øϵ΢»ý·ÖµÄÓïÑԱȻùÓÚ¹Øϵ´úÊýµÄÓïÑÔÊǸü "¸ß¼¶µÄ" »òÕß "¸üÃèÊöÐÔµÄ" ÓïÑÔ£¬ÒòΪ´úÊý£¨²¿·ÖÉÏ£©ËµÃ÷Á˲Ù×÷µÄ¹ý³Ì¶ø΢»ý·Ö°ÑÕâЩ¹ý³ÌÁô¸ø±àÒëÆ÷»òÕß½âÊÍÆ÷ÒÔ¾ö¶¨¼ÆËãµÄ×îÓÐЧ˳Ðò¡£