실습 4주차.

Slides:



Advertisements
Similar presentations
COP4540 Database Management System Midterm Review
Advertisements

Complex Integrity Constraints in SQL. Constraints over a Single Table Table Constraint: Create TABLE Sailors (sid INTEGER, sname CHAR(10), rating INTEGER,
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra) Query Formulation Exercise.
1 Database Systems 10.8, 2008 Lecture #4. 2 Course Administration Assignment #1 is due next Wed (outside 336/338). Course slides will now have black background.
1 Design Process - Where are we? Conceptual Design Conceptual Schema (ER Model) Logical Design Logical Schema (Relational Model) Step 1: ER-to-Relational.
CH4 EXERCISES 4.2. Given two relations R1 and R2, where R1 contains N1 tuples, R2 contains N2 tuples, and N2 > N1 > 0, give the min and max possible sizes.
1 Advanced SQL Queries. 2 Example Tables Used Reserves sidbidday /10/04 11/12/04 Sailors sidsnameratingage Dustin Lubber Rusty.
COP-5725 Practice Exercises
1 TRC vs DRC 한욱신. 2 Queries in TRC and DRC  TRC Q = {t| f(t)} where t is a (free) tuple variable and f(t) is a well-formed formula  DRC.
Chapter (7): Advanced SQL
Relational Algebra Rohit Khokher. Relational Algebra Set Oriented Operations UnionIntersectionDifference Cartesian Product Relation Oriented Operations.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 SQL: Queries, Programming, Triggers Chapter 5 Modified by Donghui Zhang.
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
(Uses slides from Fernando Farfan and Eduardo J. Ruiz
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
A DVANCED SQL Joe Meehean 1. SQL S ET O PERATIONS Syntax SELECT column1, column2, … FROM table1… WHERE conditions SET_KEYWORD SELECT column1, column2,
1 Lecture 11: Basic SQL, Integrity constraints
SQL and Relational Algebra Zaki Malik September 02, 2008.
Practice (Suppliers, Parts, Catalog)
COP5725 – Principles of Database Management Systems
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
CS34311 The Entity- Relationship Model. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design Conceptual.
CS34311 The Entity- Relationship Model Part II.. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
Midterm Review/Practice for SQL and Constraints. Exercise – Suppliers and Parts Suppliers(sid,sname,address) Parts(pid,pname,color) Catalog(sid, pid,price)
CSCD343- Introduction to databases- A. Vaisman1 Relational Algebra.
Relational Algebra.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 SQL: Queries, Programming, Triggers Chapter 5.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 SQL: Queries, Programming, Triggers Chapter 5.
1 Exercises of SQL uAnswer the following questions, based on the database below. wSupplier (SNO, SNAME, STATUS, CITY) wPart(PNO, PNAME, COLOR, WEIGHT)
Review for Midterm. Problem 2.7 HasPriPhy Patients address name ssn age Doctors exp_year name ssn specialty Pharmacies name address phone PharmCo name.
Data Definition After this lecture, you should be able to:
ICS 321 Fall 2009 SQL: Queries, Constraints, Triggers Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 9/8/20091Lipyeow.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra.
R EVIEW. 22 Exam Su 3:30PM - 6:30PM 2010/12/12 Room C9000.
Algebra1 After this lecture, you should be able to:  Understand the differences between SQL (Structured Query Language) and Relational Algebra expressions.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Management Systems Chapter 4 Relational Algebra.
CSCD34-Data Management Systems - A. Vaisman1 Relational Algebra.
COMP3030 Database Management System Final Review
CMPT 258 Database Systems Relational Algebra (Chapter 4)
CSCI 4333 Database Design and Implementation – Exercise (2) Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
CS34311 Translating ER Schema to Relational Model.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 SQL: Queries, Programming, Triggers Chapter 5.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Basic SQL Queries.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Advanced SQL: Aggregation and Null Values.
SQL Exercises. 1) Names of suppliers. Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)
Relational Algebra. CENG 3512 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports.
Structured Query Language IV Asma Ahmad (C. J. Date) Database Systems.
Relational Algebra Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
STRUCTURE OF PRESENTATION :
Basic SQL Queries Go over example queries, like 10 > ALL.
Relations and Functions
CS 480: Database Systems Lecture 8 February 1, 2013.
Aggregation.
Relational Algebra Chapter 4, Part A
Database Systems 10/13/2010 Lecture #4.
Relational Algebra.
Relational Databases Relational Algebra (2)
Question Which of the following plays an important role in representing information about the real world in a database? Explain briefly 1)DDL.
CS 405G: Introduction to Database Systems
CSCI 6315 Applied Database Systems – Exercise (3)
LECTURE 3: Relational Algebra
Name: _______________________________
Session 3 Welcome: To session 3-the 8th. learning sequence
Integers.
Relations and Functions
STRUCTURE OF PRESENTATION :
INSTRUCTOR: MRS T.G. ZHOU
CENG 351 File Structures and Data Managemnet
Collection of like terms
File and data base concepts
Presentation transcript:

실습 4주차

Exercise Exercise. Consider the following schema: Suppliers(sid: integer, sname: string, address: string) Parts(pid: integer, pname: string, color: string) Catalog(sid: integer, pid: integer, cost: real) The key fields are underlined, and the domain of each field is listed after the field name. Therefore sid is the key for Suppliers, pid is the key for Parts, and sid and pid together form the key for Catalog. The Catalog relation lists the prices charged for parts by Suppliers. Write the following queries in relational algebra.

1. σcolor=‘red’Parts 2. πpid σcolor=‘red’Parts <Suppliers> <Parts> <Catalog> Sid Sname Address : Pid Pname color : Sid Pid cost : 문제) Find the names of suppliers who supply some red part. 1. σcolor=‘red’Parts 2. πpid σcolor=‘red’Parts <Parts> <Parts> Pid Pname color : p12 red Pid Pname color : p12 red

3. (πpid σcolor=‘red’Parts) ▷◁ Catalog 문제) Find the names of suppliers who supply some red part. 3. (πpid σcolor=‘red’Parts) ▷◁ Catalog <Parts> <Catalog> Pid Pname color : p12 red Sid Pid cost : s3 p12 Pid Pname color : p12 red Sid cost : s3

4. πsid((πpid σcolor=‘red’Parts) ▷◁ Catalog) 문제) Find the names of suppliers who supply some red part. 4. πsid((πpid σcolor=‘red’Parts) ▷◁ Catalog) 5. πsid((πpid σcolor=‘red’Parts) ▷◁ Catalog) ▷◁ Suppliers Pid Pname color : p12 red Sid cost : s3 Pid Pname color : p12 red Sid cost : s3 Pid Pname color p12 : red Sid cost s3 : Sname Address Kim : <Suppliers> Sid Sname Address s3 Kim :

6. πsname(πsid((πpid σcolor=‘red’Parts) ▷◁ Catalog) ▷◁ Suppliers) 문제) Find the names of suppliers who supply some red part. 6. πsname(πsid((πpid σcolor=‘red’Parts) ▷◁ Catalog) ▷◁ Suppliers) Pid Pname color p12 : red Sid cost s3 : Sname Address Kim :

Exercise 1. Find the names of suppliers who supply some red part. 2. Find the sids of suppliers who supply some red or green part. 3. Find the sids of suppliers who supply some red part or are at 221 Packer Street. 4. Find the sids of suppliers who supply some red part and some green part. 5. Find the sids of suppliers who supply every part. 6. Find the sids of suppliers who supply every red part. 7. Find the sids of suppliers who supply every red or green part. 8. Find the sids of suppliers who supply every red part or supply every green part. 9. Find pairs of sids such that the supplier with the first sid charges more for some part than the supplier with the second sid. 10. Find the pids of parts supplied by at least two different suppliers. 11. Find the pids of the most expensive parts supplied by suppliers named Yosemite Sham. 1번 정답

1. 2. 3. 4. 5. 6.

7. 8. 9. 10.

11.

Q & A ?