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

Slides:



Advertisements
Similar presentations
DB glossary (focus on typical SQL RDBMS, not XQuery or SPARQL)
Advertisements

Complex Integrity Constraints in SQL. Constraints over a Single Table Table Constraint: Create TABLE Sailors (sid INTEGER, sname CHAR(10), rating INTEGER,
TURKISH STATISTICAL INSTITUTE 1 /34 SQL FUNDEMANTALS (Muscat, Oman)
COP-5725 Practice Exercises
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 SQL: Queries, Programming, Triggers Chapter 5 Modified by Donghui Zhang.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Introduction to Database Systems 1 SQL: The Query Language Relation Model : Topic 4.
SQL Constraints and Triggers
©Silberschatz, Korth and Sudarshan4.1Database System Concepts סכימה לדוגמא.
Maintaining Referential Integrity Pertemuan 2 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
חורף - תשס " ג DBMS, Design1 שימור תלויות אינטואיציה : כל תלות פונקציונלית שהתקיימה בסכמה המקורית מתקיימת גם בסכמה המפורקת. מטרה : כאשר מעדכנים.
A. Frank File Organization Indexed-Sequential File Introduction Thanks to Tamar Barnes.
שאילת שאלות שאלת חקר המפתח למנעול 1. שאילת שאלות – שאלת חקר מה ניתן לשנות ? :  בתנאים : טמפ ' או לחץ או הכלים, או הציוד  בחומרים : איכות או כמות או.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
מסדי נתונים תשס " ג 1 More on SQL קורס מסדי נתונים.
©Silberschatz, Korth and Sudarshan4.1Database System Concepts SQL n מבנה שאילתה n פונקציות צבירה.
Structured Query Language Chapter Three (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
מבוא למדעי המחשב תרגול 3 שעת קבלה : יום שני 11:00-12:00 דוא " ל :
Structured Query Language Chapter Three DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
חיפוש כתבי עת בקטלוג האוניברסיטה. חיפוש בסיסי לכתב עת אלקטרוני בקטלוג המאוחד לכתבי עת אלקטרוניים של האוניברסיטה, ניתן לבצע חיפוש עבור כתבי עת אלקטרוניים.
אתחול עצמים. אתחולים ובנאים יצירת מופע חדש של עצם כוללת: הקצאת זכרון, אתחול, הפעלת בנאים והשמה לשדות במסגרת ריצת הבנאי נקראים גם הבנאי/ם של מחלקת הבסיס.
1 IT420: Database Management and Organization SQL: Structured Query Language 25 January 2006 Adina Crăiniceanu
The Relational Model These slides are based on the slides of your text book.
Data Manipulation 11 After this lecture, you should be able to:  Understand the differences between SQL (Structured Query Language) and other programming.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Introduction to SQL Steve Perry
Review for Midterm. Problem 2.7 HasPriPhy Patients address name ssn age Doctors exp_year name ssn specialty Pharmacies name address phone PharmCo name.
SQL advanced select using Oracle 1 7. Multiple Tables: Joins and Set Operations 8. Subqueries: Nested Queries.
1 Context “Updating Union, Intersection and Difference views” - introduces a systematic approach to updating a view formed specifically by using  Union.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Recap of SQL Lab no 8 Advance Database Management System.
Practice session 3 תחביר ממשי ( קונקרטי ) ותחביר מופשט ( אבסטרקטי ) שיטות חישוב : Applicative & Normal Evaluation Partial Evaluation.
CN2180 MS SQL Server Kemtis Kunanuraksapong MSIS with Distinction, A+ MCTS, MCDST, MCP.
Practice session 3.  תחביר ממשי ( קונקרטי ) ותחביר מופשט ( אבסטרקטי )  שיטות חישוב : Applicative & Normal Evaluation.
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
SQL advanced select using Oracle 1. 2 Select Simple –data from a single table Advanced –data from more tables join sub-queries.
COMP3030 Database Management System Final Review
An Introduction to SQL For CS Overview of SQL  It is the standard language for relational systems, although imperfect  Supports data definition.
Types Prof. Yin-Fu Huang CSIE, NYUST Chapter 5. Advanced Database SystemYin-Fu Huang Relation, tuple, cardinality, attribute, degree, domain, primary.
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
Constraints Review. What is a constraint? Unique – forbids duplicate values Referencial – Foreign key Check Constraint – sets restrictions on data added.
April 2002Information Systems Design John Ogden & John Wordsworth SQL2: 1 Database Design SQL (2) John Wordsworth Department of Computer Science The University.
Views Prof. Yin-Fu Huang CSIE, NYUST Chapter 10. Advanced Database System Yin-Fu Huang 10.1Introduction Example: Var Good_Supplier View (S Where Status.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1 数据库系统概论 An Introduction to Database System 第三章 关系数据库标准语言 SQL ( 续 2 )
SQL Exercises. 1) Names of suppliers. Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)
מצגת סוף סמסטר מנחה: ד"ר גבי נקבלי מגיש: ויקטור מרגוליס
מספרים אקראיים ניתן לייצר מספרים אקראיים ע"י הפונקציה int rand(void);
Insert, Update and the rest…
ITEC 313 Database Programming
סמן נכון/לא נכון: יכולים להיות 2 חתולים (type)עם אותו שם (name)
Chapter 8 Advanced SQL Pearson Education © 2014.
Referential Integrity
SQL בסיסי – הגדרה אינדוקטיבית
אילוצי שלמות אילוצי תחום מפתחות ומפתחות זרים טריגרים triggers
The Relational Model Relational Data Model
Constraints & Triggers
בחירת חומר גלם כתב: עמרי שרון.
Based on the lecture notes of Prof. Sagiv
Referential Integrity
Updating Databases With Open SQL
CS 405G: Introduction to Database Systems
Updating Databases With Open SQL
Presentation transcript:

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’)

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? התוכן יישאר אותו הדבר!

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’);

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;

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}

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’;

2004A Q11 DCBA 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 null 2