Presentation is loading. Please wait.

Presentation is loading. Please wait.

2003B Q5 Suppliers(sid, sname, city) Select sid from suppliers where city=‘jerusalem’ or sname like ‘%Smith’ Select sid from suppliers where city=‘jerusalem’

Similar presentations


Presentation on theme: "2003B Q5 Suppliers(sid, sname, city) Select sid from suppliers where city=‘jerusalem’ or sname like ‘%Smith’ Select sid from suppliers where city=‘jerusalem’"— Presentation transcript:

1 2003B Q5 Suppliers(sid, sname, city) Select sid from suppliers where city=‘jerusalem’ or sname like ‘%Smith’ Select sid from suppliers where city=‘jerusalem’ Union all (select sid from suppliers where sname like ‘%Smith’) התוצאה של Q2 תמיד מכילה את התוצאה של Q1 ולא להיפך. למשל אם יש הרשומה הבודדת (11,’J. Smith’,’jerusalem’)

2 2003B Q11 בטבלה T ישנה שורה אחת (2,1) ובטבלה S יש שתי שורות (2,1), (2,2) כמו כן מוגדר ההדק הבא: Create table T( A integer primary key, B integer); Create table S( A integer references T(A) on delete cascade, C integer); Create trigger TT after insert on S for each row Begin Delete from T; End; / מבצעים את הפקודה Insert into S values(3,3) מה יהיה התוכן של S? TT? התוכן יישאר אותו הדבר!

3 2003A Q2 (modified) כתוב שאילתה ב SQL המוצאת מספרי מטוס של מטוסים שטווח הטיסה שלהם גדול מטווחי כל מטוסי ה ‘boeing 747’. Aircrafts(aid, aname, cruisingrange) Select a.aid from aircrafts a Where a.cruisingrange>all(select a2.cruisingrange from aircrafts a2 where a2.aname=‘Boeing 747’);

4 2003A Q5 Aircrafts(aid, aname, cruisingrange) Insert into v values(‘Boeing 707’,9999); שגיאה- aid מפתח ראשי Update v set cruisingrange=10000 where cruisingrange=9999 לא יקרה דבר Create view v as Select aname, cruisingrange From aircrafts Where cruisingrange>10,000;

5 2003A Q7 Support=60%, confidence=30% מה ניתן לומר על ה support וה- confidence של החוק Supp({a,b}->{c}) = supp({a,b,c}) = {c}) Conf ({a,b}->{c})= supp({a,b,c})/ supp({a,b}) Conf ({a}->{c})= supp({a,c})/ supp({a}) {a,b}{c} {a}{c}

6 2004A Q3 Flights(fno, from, to, distance, departs, arrives) מצא את כל הערים שמגיעות אליהן טיסות אבל אין אליהן טיסות ישירות מתל אביב. באלגברה של יחסים:  to (Flights)-  to (  from=‘TelAviv’ (Flights) ) ב SQL: Select distinct to from flights Minus /where to not in Select distinct to from flights where from=‘TelAviv’;

7 2004A Q11 DCBA 2121 2 1 R(A,B,C,D) Select A from R where B=12 and C=2 (Select A from R where B=12) Intersect (select A from R where C=2); מה היחס בין התוצאות של 1 ו -2? DCBA 3122 212 1 2 1111 1 null 2


Download ppt "2003B Q5 Suppliers(sid, sname, city) Select sid from suppliers where city=‘jerusalem’ or sname like ‘%Smith’ Select sid from suppliers where city=‘jerusalem’"

Similar presentations


Ads by Google