1Database Management Systems Exercise II  Consider the following relational schemas:  employee (person_name, street, city)  company (company_name, city)

Slides:



Advertisements
Similar presentations
Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary.
Advertisements

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.
ER Modeling Case Studies
Review Session Monday, Oct 8 Shipra Agrawal. Announcements New Gradiance assignment deadline Wednesday, Oct 10 Please read FAQs for assignments.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Huiswerk Lees delen 3.2, 3.3 van hoofdstuk 3. opgaven voor hoofdstuk 2: modelleeropgave 5.
Example T1: T2: Constraint: Susan’s salary = Jane’s salary
Relational Algebra and SQL Exercises
SQL Exercises – Part II April 11, 2017.
COP-5725 Practice Exercises
Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the.
1 Exercise 1  Given the following tables: employee (person_name, street, city)‏ works (person_name, company_name, salary)‏ company (company_name, city)‏
DB HW2 B 陳彥名 1.A π person-name (σ company-name= “ First Bank Corporation ” (works) ) 1.B π person-name,city (σ company-name= “ First Bank Corporation.
Woodgrove Bank Corp. Central City Job Fair. About Us Established in 1950 Established in ,800 employees 2,800 employees 14 branches 14 branches Locally.
June 2, 2015R&G: Database Management Systems1 Introduction to Database Systems Key to As#1 Ex. 3 Instructor: Jiawei Han based on the notes by Raghu Ramakrishnan,
Employee database: Conceptual Schema in ERD Chapter 3, page 62.
Exercise Exercise3.1 8 Exercise3.1 9 Exercise
Exercise Exercise Exercise Exercise
Exercise Exercise Exercise Exercise
Exercise Exercise6.1 7 Exercise6.1 8 Exercise6.1 9.
DB opgaven 2 Opgaven 2 Geert-Jan Houben.
Chapter 1 Exercises Accounting and the Business Environment
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Reduction of an E-R Schema to Tables A database which conforms to an E-R diagram can be represented.
Database I. Practice SQL.
Seminar #1 – Refreshing databases concepts and SQL CM036: Advanced Databases1 Seminar 1: Revisiting Databases and SQL Purpose To refresh basic concepts.
One More Normal Form Consider the dependencies: Product Company Company, State Product Is it in BCNF?
Education and Labor Market Outcomes of Young Adults Dr. Paul Harrington Center for Labor Market Studies Northeastern University Boston, Massachusetts.
The Relational Model The relational model refers to a class of data models that have relations as the data structure, and incorporate some of all the query.
Relational Model Concepts. The relational model represents the database as a collection of relations. Each relation resembles a table of values. A table.
2015 ALL CITY SOFTBALL: DIVISION I FIRST TEAM Presented to: NAME GRADE, SCHOOL JOHN A. AGUIRRE COMMISSIONER, CIF LOS ANGELES CITY SECTION.
2015 ALL CITY BOYS VOLLEYBALL: DIVISION I Presented to: NAME GRADE, SCHOOL JOHN A. AGUIRRE COMMISSIONER, CIF LOS ANGELES CITY SECTION.
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
Query Processing: Relational Algebra
Sample Problem Chapter 10 Determining social security withholding. The monthly salaries for December and the year-to-date earnings of the employees of.
The main cities Washington Washington Chicago New York Chicago New York Boston Los Angeles Boston Los Angeles San Francisco.
Advanced Database Systems
EXAMPLE. Subclasses and Superclasses Entity type may have sub-grouping that need to be represented explicitly. –Example: Employee may grouped into.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts DB Schema Design: the Entity-Relationship Model What’s the use of the E-R model? Entity Sets.
 Applied Research Project By: Matt Cohen Major: Finance.
GOALS BUSINESS MATH© Thomson/South-WesternLesson 1.1Slide 1 1.1Hourly Pay and Salary Calculate gross pay for hourly-rate employees Calculate gross pay.
Entity Relationship Diagram (2)
Relational Algebra Sample Questions.
Miss Smith 7 th Grade Civics *pgs  Money in _______ accounts earn ________  Money can be _________ when needed  Usually must keep a _______.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
CS157A Lecture 4 ER Model 2 Prof. Sin-Min Lee Department of Computer Science San Jose State University.
 Preparing for Ahead of the Game What are recruiters looking for?
ASET Relational Algebra continues…. ASET Rename Operation Allows us to name, and therefore to refer to, the results of relational-algebra expressions.
基 督 再 來 (一). 經文: 1 你們心裡不要憂愁;你們信神,也當信我。 2 在我父的家裡有許多住處;若是沒有,我就早 已告訴你們了。我去原是為你們預備地去 。 3 我 若去為你們預備了地方,就必再來接你們到我那 裡去,我在 那裡,叫你們也在那裡, ] ( 約 14 : 1-3)
Database Systems. DataBase System Haichang Gao, Software School, Xidian University 2 Major Content & Grade  Introduction*  The Relational Model** 
Top paying companies in the UK
COP Introduction to Database Structures
Entity-Relationship Model
Relational Algebra - Select & Project
Woodgrove Bank Corp. Central City Job Fair.
Chapter 2: Intro to Relational Model
Database Systems 10/13/2010 Lecture #4.
شركات المساهمة​ (corporations) Joint stock company
דיני חברות ד"ר ויקטור ח. בוגנים
Entity-Relationship Model
Woodgrove Bank Corp. Central City Job Fair.
Entity-Relationship Modeling "Extended"
Слайд-дәріс Қарағанды мемлекеттік техникалық университеті
.. -"""--..J '. / /I/I =---=-- -, _ --, _ = :;:.
II //II // \ Others Q.
Relational Algebra Sample Questions.
I1I1 a 1·1,.,.,,I.,,I · I 1··n I J,-·
In Class Exercises Phil Tayco Slide version 1.1 San Jose City College
Earnings per Share (EPS)
. '. '. I;.,, - - "!' - -·-·,Ii '.....,,......, -,
Entity-Relationship Modeling "Extended"
Entity-Relationship Modeling "Extended"
Presentation transcript:

1Database Management Systems Exercise II  Consider the following relational schemas:  employee (person_name, street, city)  company (company_name, city)  works (person_name, company_name, salary)  manages (person_name, manager_name)

2Database Management Systems Q1: Find the names of employees who work for some company in Boston.  person_name (works  city = “Boston” (company)) selectdistinct w.person_name fromworks w, company c wherew.company_name = c.company_name andc.city = “Boston”

3Database Management Systems Q2: Find the streets of employees who work for all companies in Boston.  street (employee (  person_name, company_name (works)   company_name (  city = “Boston” (company)))) select distinct e.street from employee e, works w where e.person_name = w. person_name and not exists ((select company_name from company where city = “Boston”) except (select company_name from works w1 where w1.person_name = w.person_name))

4Database Management Systems Q3: Find the names of all managers who earn more than $10,000.  person_name (  salary > (works))   manager_name (manages) select distinct w.person_name from works w, manages m where w.person_name = m.manager_name and w.salary > 10000

5Database Management Systems Q4: Find the names and cities of employees who work for First Bank Corporation and earn more than $10,000.  person_name, city (employee (  salary >  company_name = “First Bank Corporation” (works))) select person_name, city from employee where person_name in (select person_name from works where salary > and company_name = “First Bank Corporation”)

6Database Management Systems Q5: Find the names of managers who manage all employees working for First Bank Corporation.  manager_name, person_name (manages)   person_name (  company_name = “First Bank Corporation” (works)) select m.manager_name from manages m where not exists ((select person_name from works where company_name = “First Bank Corporation”) except (select m2.person_name from manages m2 where m.manager_name = m2.manager_name))

7Database Management Systems  Find the names of the employees whose salaries are higher than those of all employees living in Los Angeles. (One employee may have several works.)

8Database Management Systems  Find the names of the managers whose salaries are higher than that of at least one employee that they manage. (One employee may have several works.)