SQL בסיסי – הגדרה אינדוקטיבית

Slides:



Advertisements
Similar presentations
The Important Thing About By. The Important Thing About ******** The important thing about ***** is *****. It is true s/he can *****, *****, and *****.
Advertisements

Lesson 1.3 Unit 1, Lesson 3. Set:A collection of distinct objects Elements:All of the objects that make up a set.
FALSE. If parallel lines lie in two distinct planes, the planes must be parallel.
Union “join” two tables – the same number of columns select RA2000, DEC2000, TWOMASSID from TWOMASS WHERE ID
SQL, RA, Sets, Bags Fundamental difference between theoretical RA and practical application of it in DBMSs and SQL RA  uses sets SQL  uses bags (multisets)
Chapter (7): Advanced SQL
Algebra I Vocabulary Chapter 3. Any number that makes an inequality true is called a.
AB 11 22 33 44 55 66 77 88 99 10  20  19  18  17  16  15  14  13  12  11  21  22  23  24  25  26  27  28.
SQL (2).
GEOMETRY H2 (HOLT 1-1B) K.SANTOS UNDERSTANDING POINTS, LINES, AND PLANES (POSTULATES)
SQL Design Patterns Advanced SQL programming idioms.
Operations on Sets Union Intersection: Two sets are disjoint if their intersection is the null set. Difference A - B. Complement of a set A.
Copyright © 2004 Pearson Education, Inc.. Chapter 8 SQL-99: Schema Definition, Basic Constraints, and Queries.
Copyright © 2010 Pearson Education, Inc. All rights reserved Sec Set Operations and Compound Inequalities.
SOLVING MULTI-STEP INEQUALITIES TWO STEP INEQUALITIES Solve: 2x – 3 < Verbal Expressions for = 2x < x < 8 CHECK!
Step 1: Draw line AB AB Step 2: Draw line AC C Bisecting An Angle Step 3: Draw an arc from point B Step 4: Draw an arc from point C Intersecting the first.
Venn Diagrams/Set Theory   Venn Diagram- A picture that illustrates the relationships between two or more sets { } are often used to denote members of.
Honors Geometry.  How many lines can be passed through one point?  How many planes can be passed through one point?  How many planes can be passed.
SQL. Query SELECTList_Of_Attributes FROM List_Of_Tables [WHERECondition] [ORDER BY List_Of_Ordering_Attributes ] [GROUP BY List_Of_Grouping_Attributes.
Some of the best books of  &mid= A23D2FC75CD A23D2FC75CD7.
Compound Inequalities “And” & “Or” Graphing Solutions.
Compound Inequalities
too.
CHAPTER P SECTION 1 NOTES.
Set Notes Day 4. How are these two sets related? A={2,3,4,6} and B={5,1,2,4,3} They both have a 2, 3, and 4. This is the intersection. AB U.
1.5 Solving Inequalities Honors Algebra II. Properties of Inequalities, page 34 Property Let a, b, and c represent real numbers.
Probability Formulas The probability of more than one outcome. This is a union of the probabilities. If events are disjoint: If events are not disjoint:
Homework Review. Compound Inequalities 5.4 Are you a solution?
Understanding Points & Lines Essential Question: How do you use undefined terms as the basic elements of geometry?
1 SQL - Select Union / Intersect / Difference / Division.
Basic Definitions of Set Theory Lecture 23 Section 5.1 Wed, Mar 8, 2006.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Basic Definitions of Set Theory Lecture 24 Section 5.1 Fri, Mar 2, 2007.
1 Announcements Reading for next week: Chapter 4 Your first homework will be assigned as soon as your database accounts have been set up.  Expect an .
Math 71A 4.2 – Compound Inequalities intersection.
1 SQL – IV Grouping data from tables in SQL –The concept of grouping –GROUP BY clause –HAVING Clause –Determining whether values are unique –Group by using.
Chapter 12 Section 5 Solving Compound Inequalities.
E constante 1 control difusional x C C* BA A  BA  BA  BA  B AB E E0E0.
April 2002Information Systems Design John Ogden & John Wordsworth SQL2: 1 Database Design SQL (2) John Wordsworth Department of Computer Science The University.
Section 1.2 – 1.3 Outline Intersection  Disjoint Sets (A  B=  ) AND Union  OR Universe The set of items that are possible for membership Venn Diagrams.
EXAMPLE 4 Find a minimum distance Parking You are going to buy books. Your friend is going to buy CDs. Where should you park to minimize the distance you.
Unions and Intersections of Sets Chapter 3 Section 8.
Objective The learner will solve & graph compound inequalities.
1 Relational Algebra & SQL Query Formulation Exercise.
2( ) 8x + 14y = 4 -12x – 14y = x = x = 4 8x + 14y = 4 8(4) + 14y = y = y = -28 ___ ___ y = -2 The solution is (4, -2)
Chapter 1 Lesson 6 Solving Compound and Absolute Value Inequalities.
Midterm Review. Main Topics ER model Relational model Relational Database Design (Theory)
G2.4 – Set Operations There are some operations that we can do on sets. Some of them will look very similar to operations from algebra. August 2006 Copyright.
Relational Algebra and SQL
Database Management Systems
Database Management Systems
SQL - כתיבת שאילתות למתחילים
SQL בסיסי – הגדרה אינדוקטיבית
Exercise 6B Q.5(b) Angle between VAB and ABCD.
دور المجتمع المدني في ترشيد وتحسين كفاءة الطاقة آفاق جديدة ومتجددة...
Systems of equations.
CMPT 354: Database System I
Statements joined by “And” (Conjunctions)
--....,,,. _,-->r 1Jl oEUKAITf INTERNATIONAL T B RA 0 D 7 I 0 N b G.
Reading: ‘Washington, DC’
SQL set operators and modifiers.
Set Operations Union Intersect Minus.
books WARM-uP Lesson 1 Independent work Exit card
Section 5.4 Day 1 Algebra 1.
Lesson 2.3 Subsets of planes pp
1C-1D, 1F Number Sets 7A-7C Sets and Interval Notation

1.3 Early Definitions & Postulates
Rays and Angles SY Source: Geometry (2007) by Ron Larson et al.
Presentation transcript:

SQL בסיסי – הגדרה אינדוקטיבית SELECT DISTINCT c1,c2,…,ck FROM T1,T2,…,Tn WHERE θ T1,T2,…,Tn - שמות של טבלאות. השמות חייבים להיות שונים. c1,c2,…,ck - שמות של עמודות בטבלאות. יש לציין את השם הפנימי במקרה של כפילויות. θ – תנאי בין שני שדות (>,<,=,<>,…), או תנאי מורכב מתנאים אחרים (ע"י AND, NOT, ...) ללא פעולות אריתמטיות. ללא השוואות לקבוצת ערכים. אביב 2012 SQL to RA : SQL

SQL בסיסי – הגדרה אינדוקטיבית פעולות על קבוצות E1 UNION E2 E1 EXCEPT E2 E1 INTERSECT E2 E1,E2 – שאילתות SQL בסיסי אביב 2012 SQL to RA : SQL

SQL בסיסי – הגדרה אינדוקטיבית השמה: מתן שם לתוצאת שאילתה ושם שונה לעמודות. השם החדש יכול להופיע בהמשך בשאילתות SQL בסיסי. CREATE VIEW V(a1,b1,...) AS E E – שאילתת SQL בסיסי V – שם חדש לתוצאת השאילתה. אביב 2012 SQL to RA : SQL

SQL בסיסי – תרגום ל-RA נרצה לתרגם סדרת ביטויי SQL בסיסי ל-RA. r := E E – ביטוי ב-RA. r – שם של רלציה. ערך r הוא ערך הביטוי המקורי. זוהי לא רלציה חדשה. אביב 2012 SQL to RA : SQL

πc1,c2,…,ck(σθ(T1×T2×…×Tn)) SQL בסיסי ו-RA SELECT DISTINCT c1,c2,…,ck FROM T1,T2,…,Tn WHERE θ תרגום השאילתה ל-RA: πc1,c2,…,ck(σθ(T1×T2×…×Tn)) אביב 2012 SQL to RA : SQL

SQL בסיסי ו-RA E1 UNION E2 E1 EXCEPT E2 E1 INTERSECT E2 אביב 2012 SQL to RA : SQL

SQL בסיסי ו-RA CREATE VIEW V(a1,b1,...) AS E אם עמודות E הם (a,b,…), אז התרגום ל-RA הוא: V:=ρa→a1,b→b1,…(E) אביב 2012 SQL to RA : SQL

מסקנות טענה: לכל שאילתה ב-SQL בסיסי ניתן לכתוב ביטוי שקול ב-RA עם השמות. הוכחה באינדוקציית מבנה. מהרצאה: לכל ביטוי RAעם השמות ניתן לכתוב שאילתה שקולה ב-SQL בסיסי. מסקנה: RA עם השמות שקולה ל-SQL בסיסי! אביב 2012 SQL to RA : SQL

SQL בסיסי – דוגמה (1/5) האם לשאילתה הבאה יש שאילתה שקולה ב-SQL בסיסי? SELECT DISTINCT B.Book_Name AS TheName FROM Books AS B WHERE B.Book_Name NOT IN ( SELECT B2.Book_Name FROM BOOKS B2 WHERE B2.Year <> B.Year) אביב 2012 SQL to RA : SQL

SQL בסיסי – דוגמה (2/5) תשובה: כן! תחילה ניצור טבלה וירטואלית נוספת: CREATE VIEW Books2(Book_Name,Year) AS SELECT Book_Name,Year FROM Books; אביב 2012 SQL to RA : SQL

SQL בסיסי – דוגמה (3/5) נחשב את התוצאה: CREATE VIEW Result(TheName) AS SELECT DISTINCT Book_Name FROM Books EXCEPT SELECT DISTINCT Books.Book_Name FROM Books, Books2 WHERE Books.Book_Name = Books2.Book_Name AND Books.Year <> Books2.Year אביב 2012 SQL to RA : SQL

SQL בסיסי – דוגמה (4/5) לקבלת התוצאה: SELECT TheName FROM Result WHERE true אביב 2012 SQL to RA : SQL

SQL בסיסי – דוגמה (4/5) πBook_Name(Books)\ πBook_Name( (Books×Books2) תרגום ל-RA עם השמות: Books2 := Books πBook_Name(Books)\ πBook_Name( σBooks.Book_Name=Book2.Book_Name∧Books.Year<>Books2.Year (Books×Books2) ) אביב 2012 SQL to RA : SQL

SQL בסיסי – דוגמה נוספת האם לשאילתה הבאה יש שאילתה שקולה ב-SQL בסיסי? SELECT Year, COUNT(Book_Name) FROM Books GROUP BY Year תשובה: לא! הסבר: בשאילתה זו, תחום הערכים בתוצאה יכול להיות שונה מתחום הערכים ברלציות. זה לא ייתכן ב-RA, ולכן גם לא ב-SQL בסיסי. אביב 2012 SQL to RA : SQL