# Figure 4.12.Insurancedatabase.

Save this PDF as:

Size: px
Start display at page:

## Transcription

2 44 Chapter 4 SQL d. Find all employees in the database who live in the same cities as the companies for which they work. e. Find all employees in the database who live in the same cities and on the same streets as do their managers. f. Find all employees in the database who do not work for First Bank Corporation. g. Find all employees in the database who earn more than each employee of Small Bank Corporation. h. Assume that the companies may be located in several cities. Find all companies located in every city in which Small Bank Corporation is located. i. Find all employees who earn more than the average salary of all employees of their company. j. Find the company that has the most employees. k. Find the company that has the smallest payroll. l. Find those companies whose employees earn a higher salary, on average, than the average salary at First Bank Corporation. Answer: a. Find the names of all employees who work for First Bank Corporation. where company-name = First Bank Corporation b. Find the names and cities of residence of all employees who work for First Bank Corporation. select e.employee-name, city from employee e, works w where w.company-name = First Bank Corporation and w.employee-name = e.employee-name c. Find the names, street address, and cities of residence of all employees who work for First Bank Corporation and earn more than \$10,000. If people may work for several companies, the following solution will only list those who earn more than \$10,000 per annum from First Bank Corporation alone. select * from employee where employee-name in ( where company-name = First Bank Corporation and salary 10000) As in the solution to the previous query, we can use a join to solve this one also. d. Find all employees in the database who live in the same cities as the companies for which they work.

3 Exercises 45 select e.employee-name from employee e, works w, company c where e.employee-name = w.employee-name and e.city = c.city and w.company -name = c.company -name e. Find all employees in the database who live in the same cities and on the same streets as do their managers. select P.employee-name from employee P, employee R, manages M where P.employee-name = M.employee-name and M.manager-name = R.employee-name and P.street = R.street and P.city = R.city f. Find all employees in the database who do not work for First Bank Corporation. The following solution assumes that all people work for exactly one company. where company-name First Bank Corporation If one allows people to appear in the database (e.g. in employee) butnot appear in works, or if people may have jobs with more than one company, the solution is slightly more complicated. from employee where employee-name not in ( where company-name = First Bank Corporation ) g. Find all employees in the database who earn more than every employee of Small Bank Corporation. The following solution assumes that all people work for at most one company. where salary > all (select salary where company-name = Small Bank Corporation ) If people may work for several companies and we wish to consider the total earnings of each person, the problem is more complex. It can be solved by using a nested subquery, but we illustrate below how to solve it using the with clause.

4 46 Chapter 4 SQL with emp-total-salary as (, sum(salary) as total-salary group by employee-name ) from emp-total-salary where total-salary > all (select total-salary from emp-total-salary, works where works.company-name = Small Bank Corporation and emp-total-salary.employee-name = works.employee-name ) h. Assume that the companies may be located in several cities. Find all companies located in every city in which Small Bank Corporation is located. The simplest solution uses the contains comparison which was included in the original System R Sequel language but is not present in the subsequent SQL versions. select T.company-name from company T where (select R.city from company R where R.company-name = T.company-name) contains (select S.city from company S where S.company-name = Small Bank Corporation ) Below is a solution using standard SQL. select S.company-name from company S where not exists ((select city from company where company-name = Small Bank Corporation ) except (select city from company T where S.company-name = T.company-name)) i. Find all employees who earn more than the average salary of all employees of their company. The following solution assumes that all people work for at most one company.

5 Exercises 47 employee (employee-name, street, city) works (employee-name, company-name, salary) company (company-name, city) manages (employee-name, manager-name) Figure Employee database. T where salary > (select avg (salary) S where T.company-name = S.company-name) j. Find the company that has the most employees. select company-name group by company-name having count (distinct employee-name) >= all (select count (distinct employee-name) group by company-name) k. Find the company that has the smallest payroll. select company-name group by company-name having sum (salary) <= all (select sum (salary) group by company-name) l. Find those companies whose employees earn a higher salary, on average, than the average salary at First Bank Corporation. select company-name group by company-name having avg (salary) > (select avg (salary) where company-name = First Bank Corporation ) 4.3 Consider the relational database of Figure Give an expression in SQL for each of the following queries. a. Modify the database so that Jones now lives in Newtown. b. Give all employees of First Bank Corporation a 10 percent raise. c. Give all managers of First Bank Corporation a 10 percent raise. d. Give all managers of First Bank Corporation a 10 percent raise unless the salary becomes greater than \$100,000; in such cases, give only a 3 percent raise.

6 48 Chapter 4 SQL e. Delete all tuples in the works relation for employees of Small Bank Corporation. Answer: The solution for part 0.a assumes that each person has only one tuple in the employee relation. The solutions to parts 0.c and 0.d assume that each person works for at most one company. a. Modify the database so that Jones now lives in Newtown. update employee set city = Newton where person-name = Jones b. Give all employees of First Bank Corporation a 10-percent raise. update works set salary = salary * 1.1 where company-name = First Bank Corporation c. Give all managers of First Bank Corporation a 10-percent raise. update works set salary = salary * 1.1 where employee-name in (select manager-name from manages) and company-name = First Bank Corporation d. Give all managers of First Bank Corporation a 10-percent raise unless the salary becomes greater than \$100,000; in such cases, give only a 3-percent raise. update works T set T.salary = T.salary * 1.03 where T.employee-name in (select manager-name from manages) and T.salary * 1.1 > and T.company-name = First Bank Corporation update works T set T.salary = T.salary * 1.1 where T.employee-name in (select manager-name from manages) and T.salary * 1.1 <= and T.company-name = First Bank Corporation SQL-92 provides a case operation (see Exercise 4.11), using which we give a more concise solution:-

7 Exercises 49 update works T set T.salary = T.salary (case when (T.salary 1.1 > ) then 1.03 else 1.1 ) where T.employee-name in (select manager-name from manages) and T.company-name = First Bank Corporation e. Delete all tuples in the works relation for employees of Small Bank Corporation. delete works where company-name = Small Bank Corporation 4.4 Let the following relation schemas be given: R =(A, B, C) S =(D, E, F) Let relations r(r) and s(s) be given. Give an expression in SQL that is equivalent to each of the following queries. a. Π A (r) b. σ B =17 (r) c. r s d. Π A,F (σ C = D (r s)) Answer: a. Π A (r) b. σ B =17 (r) c. r s d. Π A,F (σ C = D (r s)) select distinct A from r select * from r where B = 17 select distinct * from r, s select distinct A, F from r, s where C = D 4.5 Let R = (A, B, C), andletr 1 and r 2 both be relations on schema R. Givean expression in SQL that is equivalent to each of the following queries. a. r 1 r 2 b. r 1 r 2

8 50 Chapter 4 SQL c. r 1 r 2 d. Π AB (r 1 ) Π BC (r 2 ) Answer: a. r 1 r 2 (select * from r1) union (select * from r2) b. r 1 r 2 We can write this using the intersect operation, which is the preferred approach, but for variety we present an solution using a nested subquery. select * from r1 where (A, B, C) in (select * from r2) c. r 1 r 2 select from r1 where (A, B, C) not in (select from r2) This can also be solved using the except clause. d. Π AB (r 1 ) Π BC (r 2 ) select r1.a, r2.b, r3.c from r1, r2 where r1.b = r2.b 4.6 Let R = (A, B) and S = (A, C), andletr(r)and s(s) be relations. Write an expression in SQL for each of the queries below: a. {< a> b(<a,b> r b = 17)} b. {< a,b,c> <a,b> r <a,c> s} c. {< a> c(<a,c> s b 1,b 2 (<a,b 1 > r <c,b 2 > r b 1 > b 2 ))} Answer: a. {< a> b(<a,b> r b = 17)} select distinct A from r where B = 17 b. {< a,b,c> <a,b> r <a,c> s)}

### Exercises. a. Find the total number of people who owned cars that were involved in accidents

42 Chapter 4 SQL Exercises 4.1 Consider the insurance database of Figure 4.12, where the primary keys are underlined. Construct the following SQL queries for this relational database. a. Find the total

### SQL. Solutions to Practice Exercises

C H A P T E R 3 SQL Solutions to Practice Exercises 3.1 Note: The participated relation relates drivers, cars, and accidents. a. Note: this is not the same as the total number of accidents in 1989. We

### Introduction to SQL C H A P T E R3. Exercises

C H A P T E R3 Introduction to SQL Exercises 3.1 Write the following queries in SQL, using the university schema. (We suggest you actually run these queries on a database, using the sample data that we

### Relationele Databases 2002/2003

1 Relationele Databases 2002/2003 Hoorcollege 5 22 mei 2003 Jaap Kamps & Maarten de Rijke April Juli 2003 Plan voor Vandaag Praktische dingen 3.8, 3.9, 3.10, 4.1, 4.4 en 4.5 SQL Aantekeningen 3 Meer Queries.

### Introduction to SQL (3.1-3.4)

CSL 451 Introduction to Database Systems Introduction to SQL (3.1-3.4) Department of Computer Science and Engineering Indian Institute of Technology Ropar Narayanan (CK) Chatapuram Krishnan! Summary Parts

### Exercise 1: Relational Model

Exercise 1: Relational Model 1. Consider the relational database of next relational schema with 3 relations. What are the best possible primary keys in each relation? employ(person_name, street, city)

### D B M G. SQL language: basics. Set operators. The UNION operator The INTERSECT operator The EXCEPT operator. SQL language: set operators

SQL language: basics Set operators Set operators The UNION operator The INTERSECT operator The EXCEPT operator 2013 Politecnico di Torino 1 Set operators The UNION operator The UNION operator Set union

### G.H. Raisoni College of Engineering & Management, Amravati. Question Bank (DBMS) Third Year CSE

G.H. Raisoni College of Engineering & Management, Amravati. Question Bank (DBMS) Third Year CSE UNIT 1 Q.1. Explain the three levels of data abstraction. Q.2. What are the advantages and disadvantages

### Relational Algebra. Query Languages Review. Operators. Select (σ), Project (π), Union ( ), Difference (-), Join: Natural (*) and Theta ( )

Query Languages Review Relational Algebra SQL Set operators Union Intersection Difference Cartesian product Relational Algebra Operators Relational operators Selection Projection Join Division Douglas

### SQL Query & Modification

CS145 Lecture Notes #7 SQL Query & Modification Introduction SQL Structured Query Language Pronounced S-Q-L or sequel The query language of every commercial RDBMS Evolution of SQL standard: SQL89 SQL92

### 1 Structured Query Language: Again. 2 Joining Tables

1 Structured Query Language: Again So far we ve only seen the basic features of SQL. More often than not, you can get away with just using the basic SELECT, INSERT, UPDATE, or DELETE statements. Sometimes

### Answer Key. UNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division

Answer Key UNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division CS186 Fall 2003 Eben Haber Midterm Midterm Exam: Introduction to Database Systems This exam has

### Chapter 13: Query Optimization

Chapter 13: Query Optimization Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 13: Query Optimization Introduction Transformation of Relational Expressions Catalog

### Data Structure: Relational Model. Programming Interface: JDBC/ODBC. SQL Queries: The Basic From

Data Structure: Relational Moel Relational atabases: Schema + Data Schema (also calle scheme): collection of tables (also calle relations) each table has a set of attributes no repeating relation names,

### Lecture 2: Part I. Integrity Rules: Applicable to All Databases. Integrity Rules. Key constraint Entity integrity Referential integrity

Lecture 2: Part I Integrity Rules Relational integrity rules 1 Integrity Rules: Applicable to a Particular Database E.G. An employee s salary must be in the range \$30,000 to \$100,000. See section 8.6 Elmasri

### Relation Definition. More Definitions. Properties of a Relation. Even More Definitions. Example. CSE 444: Database Internals

Relation Definition CSE 444: Database Internals Database is collection of relations Lecture 2 Review of the Relational Model and SQL Relation R is subset of S 1 x S 2 x x S n Where S i is the domain of

### Information Systems SQL. Nikolaj Popov

Information Systems SQL Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria popov@risc.uni-linz.ac.at Outline SQL Table Creation Populating and Modifying

### Lab Manual. Database Systems COT-313 & Database Management Systems Lab IT-216

Lab Manual Database Systems COT-313 & Database Management Systems Lab IT-216 Lab Instructions Several practicals / programs? Whether an experiment contains one or several practicals /programs One practical

### Extended Operators in SQL and Relational Algebra

Extended Operators in SQL and Relational Algebra T. M. Murali September 15, 2010 Bags or Sets? So far, we have said that relational algebra and SQL operate on relations that are sets of tuples. Real RDBMSs

### Advanced SQL. Lecture 3. Outline. Unions, intersections, differences Subqueries, Aggregations, NULLs Modifying databases, Indexes, Views

Advanced SQL Lecture 3 1 Outline Unions, intersections, differences Subqueries, Aggregations, NULLs Modifying databases, Indexes, Views Reading: Textbook chapters 6.2 and 6.3 from SQL for Nerds : chapter

### Functional Dependencies and Finding a Minimal Cover

Functional Dependencies and Finding a Minimal Cover Robert Soulé 1 Normalization An anomaly occurs in a database when you can update, insert, or delete data, and get undesired side-effects. These side

### Programming Interface: JDBC/ODBC. Applications View of a Relational Database Management (RDBMS) System

Applications View of a Relational Database Management (RDBMS) System Applications:. Persistent data structure Large volume of data Independent from processes using the data High-level programming interface

### SQL Nested & Complex Queries. CS 377: Database Systems

SQL Nested & Complex Queries CS 377: Database Systems Recap: Basic SQL Retrieval Query A SQL query can consist of several clauses, but only SELECT and FROM are mandatory SELECT FROM

### Oracle SQL. Course Summary. Duration. Objectives

Oracle SQL Course Summary Identify the major structural components of the Oracle Database 11g Create reports of aggregated data Write SELECT statements that include queries Retrieve row and column data

### Structured Query Language (SQL)

Objectives of SQL Structured Query Language (SQL) o Ideally, database language should allow user to: create the database and relation structures; perform insertion, modification, deletion of data from

### SOLUTIONS SOLUTIONS SOLUTIONS SOLUTIONS

York University Test 1 / Fall 2008 Department of Computer Science and Engineering CSE3421 This is a closed book, 40 minutes test No questions are allowed during the test. If in doubt, write down your doubts

### SQL Query Evaluation. Winter 2006-2007 Lecture 23

SQL Query Evaluation Winter 2006-2007 Lecture 23 SQL Query Processing Databases go through three steps: Parse SQL into an execution plan Optimize the execution plan Evaluate the optimized plan Execution

### Oracle Database: SQL and PL/SQL Fundamentals

Oracle University Contact Us: 1.800.529.0165 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This course is designed to deliver the fundamentals of SQL and PL/SQL along

### SUBQUERIES AND VIEWS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 6

SUBQUERIES AND VIEWS CS121: Introduction to Relational Database Systems Fall 2015 Lecture 6 String Comparisons and GROUP BY 2! Last time, introduced many advanced features of SQL, including GROUP BY! Recall:

### Chapter 14: Query Optimization

Chapter 14: Query Optimization Database System Concepts 5 th Ed. See www.db-book.com for conditions on re-use Chapter 14: Query Optimization Introduction Transformation of Relational Expressions Catalog

### Part 4: Database Language - SQL

Part 4: Database Language - SQL Junping Sun Database Systems 4-1 Database Languages and Implementation Data Model Data Model = Data Schema + Database Operations + Constraints Database Languages such as

### Entity Relationship Model

C H A P T E R 2 Entity Relationship Model Exercises 2.2 Answer: See Figure 2.1 2.4 Answer: See Figure 2.2. In the answer given here, the main entity sets are,, -offering, and instructor. The entity set

### Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle University Contact Us: + 38516306373 Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training delivers the

### Part A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems

CSC 74 Database Management Systems Topic #0: SQL Part A: Data Definition Language (DDL) Spring 00 CSC 74: DBMS by Dr. Peng Ning Spring 00 CSC 74: DBMS by Dr. Peng Ning Schema and Catalog Schema A collection

### Oracle Database: SQL and PL/SQL Fundamentals

Oracle University Contact Us: +966 12 739 894 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training is designed to

### Standard Query Language. SQL: Data Manipulation Transparencies

Standard Query Language SQL: Data Manipulation Transparencies Objectives Purpose and importance of SQL. How to retrieve data from database using SELECT and: Use compound WHERE conditions. Sort query results

### unisys OS 2200 Relational Data Management System (RDMS 2200) and IPF SQL Interface End Use Guide imagine it. done. ClearPath OS 2200 12.

unisys imagine it. done. OS 2200 Relational Data Management System (RDMS 2200) and IPF SQL Interface End Use Guide ClearPath OS 2200 12.1 Release June 2010 7831 0778 003 NO WARRANTIES OF ANY NATURE ARE

### Effective Use of SQL in SAS Programming

INTRODUCTION Effective Use of SQL in SAS Programming Yi Zhao Merck & Co. Inc., Upper Gwynedd, Pennsylvania Structured Query Language (SQL) is a data manipulation tool of which many SAS programmers are

### Advance DBMS. Structured Query Language (SQL)

Structured Query Language (SQL) Introduction Commercial database systems use more user friendly language to specify the queries. SQL is the most influential commercially marketed product language. Other

### Using SQL Queries to Insert, Update, Delete, and View Data: Joining Multiple Tables. Lesson C Objectives. Joining Multiple Tables

Using SQL Queries to Insert, Update, Delete, and View Data: Joining Multiple Tables Wednesay 9/24/2014 Abdou Illia MIS 4200 - Fall 2014 Lesson C Objectives After completing this lesson, you should be able

### Instructor: Amol Deshpande

Instructor: Amol Deshpande amol@cs.umd.edu Data Models Conceptual representa8on of the data Data Retrieval How to ask ques8ons of the database How to answer those ques8ons Data Storage How/where to store

### 2071B Querying Microsoft SQL Server 2000 with Transact-SQL

Course: 2071B Querying Microsoft SQL Server 2000 with Transact-SQL Description: The goal of this course is to provide students with the technical skills required to write basic Transact-SQL queries for

### Graham Kemp (telephone 772 54 11, room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.

CHALMERS UNIVERSITY OF TECHNOLOGY Department of Computer Science and Engineering Examination in Databases, TDA357/DIT620 Tuesday 17 December 2013, 14:00-18:00 Examiner: Results: Exam review: Grades: Graham

### CS 338 Join, Aggregate and Group SQL Queries

CS 338 Join, Aggregate and Group SQL Queries Bojana Bislimovska Winter 2016 Outline SQL joins Aggregate functions in SQL Grouping in SQL HAVING clause SQL Joins Specifies a table resulting from a join

### Given following relations:

Exercise 1 (SQL [40 points] Given following relations: Customers (cid, cname, city, discnt Agents (aid, aname, city, percent Products (pid, pname, city, quantity, price Orders (ordno, month, cid, aid,

### Relational Database Design

Relational Database Design To generate a set of relation schemas that allows - to store information without unnecessary redundancy - to retrieve desired information easily Approach - design schema in appropriate

### More on SQL. Juliana Freire. Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan

More on SQL Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan SELECT A1, A2,, Am FROM R1, R2,, Rn WHERE C1, C2,, Ck Interpreting a Query

### Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Outline More Complex SQL Retrieval Queries

### Relationele Databases 2002/2003

1 Relationele Databases 2002/2003 Hoorcollege 7 12 juni 2003 Jaap Kamps & Maarten de Rijke April Juli 2003 Praktische dingen 6.2 6.3 6.5 6.7 Plan voor Vandaag Theorie Silberschatz et al: hoofdstuk 7 (

### 3. Relational Model and Relational Algebra

ECS-165A WQ 11 36 3. Relational Model and Relational Algebra Contents Fundamental Concepts of the Relational Model Integrity Constraints Translation ER schema Relational Database Schema Relational Algebra

### Chapter 4: SQL. Basic Structure

Chapter 4: SQL Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries Derived Relations Views Modification of the Database Joined Relations Data Definition Language Embedded SQL

### Oracle Database 12c: Introduction to SQL Ed 1.1

Oracle University Contact Us: 1.800.529.0165 Oracle Database 12c: Introduction to SQL Ed 1.1 Duration: 5 Days What you will learn This Oracle Database: Introduction to SQL training helps you write subqueries,

### Intermediate SQL C H A P T E R4. Practice Exercises. 4.1 Write the following queries in SQL:

C H A P T E R4 Intermediate SQL Practice Exercises 4.1 Write the following queries in SQL: a. Display a list of all instructors, showing their ID, name, and the number of sections that they have taught.

### CS143: Query and Update in SQL

CS143: Query and Update in SQL Book Chapters (4th) Chapter 4.1-6, 4.8-10, 3.3.4 (5th) Chapter 3.1-8, 3.10-11 (6th) Chapter 3.1-9, 4.1, 4.3 Things to Learn SQL DML for SQL Structured Query Language The

### Week 4 & 5: SQL. SQL as a Query Language

Week 4 & 5: SQL The SQL Query Language Select Statements Joins, Aggregate and Nested Queries Insertions, Deletions and Updates Assertions, Views, Triggers and Access Control SQL 1 SQL as a Query Language

### Elena Baralis, Silvia Chiusano Politecnico di Torino. Pag. 1. Physical Design. Phases of database design. Physical design: Inputs.

Phases of database design Application requirements Conceptual design Database Management Systems Conceptual schema Logical design ER or UML Physical Design Relational tables Logical schema Physical design

### Quiz 2: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354

Quiz 2: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354 1. (10) Convert the below E/R diagram to a relational database schema, using each of the following approaches: (3)The straight

### Introduction to SQL: Data Retrieving

Introduction to SQL: Data Retrieving Ruslan Fomkin Databasdesign för Ingenjörer 1056F Structured Query Language (SQL) History: SEQUEL (Structured English QUery Language), earlier 70 s, IBM Research SQL

### Similarly for INTERSECT, EXCEPT = Find the drinkers and beers such that the drinker. likes the beer and frequents a bar that serves it.

Union, Intersection, Dierence \Relation UNION relation" produces the union of the two relations. Similarly for INTERSECT, EXCEPT = intersection and set dierence. But: in Oracle 7.3.2 set dierence is MINUS,

### Oracle Database 11g SQL

AO3 - Version: 2 19 June 2016 Oracle Database 11g SQL Oracle Database 11g SQL AO3 - Version: 2 3 days Course Description: This course provides the essential SQL skills that allow developers to write queries

### ให p, q, r และ s เป นพห นามใดๆ จะได ว า

เศษส วนของพห นาม ให A และ B เป นพห นาม พห นามใดๆ โดยท B 0 เร ยก B A ว า เศษส วนของพห นาม การดาเน นการของเศษส วนของพห นาม ให p, q, r และ s เป นพห นามใดๆ จะได ว า Q P R Q P Q R Q P R Q P Q R R Q P S P Q

### Relational Databases

Relational Databases Jan Chomicki University at Buffalo Jan Chomicki () Relational databases 1 / 18 Relational data model Domain domain: predefined set of atomic values: integers, strings,... every attribute

### SQL Development Using Oracle

SQL Development Using Oracle Course Summary Identify the major structural components of the Oracle Database 11g Create reports of aggregated data Write SELECT statements that include queries Retrieve row

### Q4. What are data model? Explain the different data model with examples. Q8. Differentiate physical and logical data independence data models.

FAQs Introduction to Database Systems and Design Module 1: Introduction Data, Database, DBMS, DBA Q2. What is a catalogue? Explain the use of it in DBMS. Q3. Differentiate File System approach and Database

### SQL QUERIES. CS121: Introduction to Relational Database Systems Fall 2016 Lecture 5

SQL QUERIES CS121: Introduction to Relational Database Systems Fall 2016 Lecture 5 SQL Queries 2 SQL queries use the SELECT statement General form is: SELECT A 1, A 2,... FROM r 1, r 2,... WHERE P; r i

### 14 Databases. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

14 Databases 14.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define a database and a database management system (DBMS)

### Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

D80198GC10 Oracle Database 12c SQL and Fundamentals Summary Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff Level Professional Delivery Method Instructor-led

### SQL: Queries, Programming, Triggers

SQL: Queries, Programming, Triggers Chapter 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 R1 Example Instances We will use these instances of the Sailors and Reserves relations in

### Overview of Transaction Management 221

Overview of Transaction Management 221 1. The following schedule results in a write-read conflict: T2:R(X), T2:R(Y), T2:W(X), T1:R(X)... T1:R(X) is a dirty read here. 2. The following schedule results

### Example Instances. SQL: Queries, Programming, Triggers. Conceptual Evaluation Strategy. Basic SQL Query. A Note on Range Variables

SQL: Queries, Programming, Triggers Chapter 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Example Instances We will use these instances of the Sailors and Reserves relations in our

### UNIT 6. Structured Query Language (SQL) Text: Chapter 5

UNIT 6 Structured Query Language (SQL) Text: Chapter 5 Learning Goals Given a database (a set of tables ) you will be able to express a query in SQL, involving set operators, subqueries and aggregations

### SQL: Queries, Programming, Triggers

SQL: Queries, Programming, Triggers CSC343 Introduction to Databases - A. Vaisman 1 R1 Example Instances We will use these instances of the Sailors and Reserves relations in our examples. If the key for

### Hierarchical Model APPENDIXE. E.1 Basic Concepts

APPENDIXE Hierarchical Model In the network model, the data are represented by collections of records and relationships between data are represented by links. This structure holds for the hierarchical

### Chapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL

Chapter 9 Joining Data from Multiple Tables Oracle 10g: SQL Objectives Identify a Cartesian join Create an equality join using the WHERE clause Create an equality join using the JOIN keyword Create a non-equality

### Instant SQL Programming

Instant SQL Programming Joe Celko Wrox Press Ltd. INSTANT Table of Contents Introduction 1 What Can SQL Do for Me? 2 Who Should Use This Book? 2 How To Use This Book 3 What You Should Know 3 Conventions

### SQL: WHERE Subqueries and Other Syntactic Sugar

SQL: WHERE Subqueries and Other Syntactic Sugar David Toman School of Computer Science University of Waterloo Introduction to Databases CS348 David Toman (University of Waterloo) SQL Syntax Sugar 1 / 17

### Chapter 8. SQL-99: SchemaDefinition, Constraints, and Queries and Views

Chapter 8 SQL-99: SchemaDefinition, Constraints, and Queries and Views Data Definition, Constraints, and Schema Changes Used to CREATE, DROP, and ALTER the descriptions of the tables (relations) of a database

### Triggers & Packages. {INSERT [OR] UPDATE [OR] DELETE}: This specifies the DML operation.

Triggers & Packages An SQL trigger is a mechanism that automatically executes a specified PL/SQL block (referred to as the triggered action) when a triggering event occurs on the table. The triggering

### Databases. Chapter 14. Objectives After studying this chapter, students should be able to: Definition 14-1 INTRODUCTION

Chapter 14 Databases 14.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, students should be able to: 14.2 Define a database and a database management system

### COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries

COMP 5138 Relational Database Management Systems Week 5 : Basic COMP5138 "Relational Database Managment Systems" J. Davis 2006 5-1 Today s Agenda Overview Basic Queries Joins Queries Aggregate Functions

### 2. Basic Relational Data Model

2. Basic Relational Data Model 2.1 Introduction Basic concepts of information models, their realisation in databases comprising data objects and object relationships, and their management by DBMS s that

### Online EFFECTIVE AS OF JANUARY 2013

2013 A and C Session Start Dates (A-B Quarter Sequence*) 2013 B and D Session Start Dates (B-A Quarter Sequence*) Quarter 5 2012 1205A&C Begins November 5, 2012 1205A Ends December 9, 2012 Session Break

### Database Constraints and Design

Database Constraints and Design We know that databases are often required to satisfy some integrity constraints. The most common ones are functional and inclusion dependencies. We ll study properties of

### Company Setup Payroll Groups Tab

Reference Sheet Company Setup Payroll Groups Tab Use the Payroll Groups tab to create groups of employees that are associated with payroll functions. Specifically, you can use payroll groups to determine

### Introduction to Microsoft Jet SQL

Introduction to Microsoft Jet SQL Microsoft Jet SQL is a relational database language based on the SQL 1989 standard of the American Standards Institute (ANSI). Microsoft Jet SQL contains two kinds of

### Overview of Database Management Systems

Overview of Database Management Systems Goals: DBMS basic concepts Introduce underlying managerial issues Prepare for discussion of uses of DBMS, such as OLAP and database mining 1 Overview of Database

### RELATIONAL DATABASE DESIGN

RELATIONAL DATABASE DESIGN g Good database design - Avoiding anomalies g Functional Dependencies g Normalization & Decomposition Using Functional Dependencies g 1NF - Atomic Domains and First Normal Form

### GROUP BY and HAVING. SELECT MIN (S.age) FROM Sailors S WHERE S.rating = i. For i = 1, 2,..., 10:

SQL - 4 Week 9 GROUP BY and HAVING So far, we ve applied aggregate operators to all (qualifying) tuples. Sometimes, we want to apply them to each of several groups of tuples. Consider: Find the age of

Specifying Updates in SQL There are three SQL commands to modify the database INSERT, DELETE, and UPDATE UCSD CSE132B Slide 23/76 INSERT In its simplest form, it is used to add one or more tuples to a

### Relational Database: Additional Operations on Relations; SQL

Relational Database: Additional Operations on Relations; SQL Greg Plaxton Theory in Programming Practice, Fall 2005 Department of Computer Science University of Texas at Austin Overview The course packet

### The Relational Data Model and Relational Database Constraints

The Relational Data Model and Relational Database Constraints Chapter Outline Relational Model Concepts Relational Model Constraints and Relational Database Schemas Update Operations and Dealing with Constraint

### Fuld Skolerapport for Søhusskolen, i Odense kommune, for skoleår 2013/2014 for klassetrin(ene) 9. med reference Tilsvarende klassetrin i kommunen

Side 1 af 41 Side 2 af 41 Side 3 af 41 Side 4 af 41 Side 5 af 41 Side 6 af 41 Side 7 af 41 Side 8 af 41 Side 9 af 41 Side 10 af 41 Side 11 af 41 Side 12 af 41 Side 13 af 41 Side 14 af 41 Side 15 af 41

### Fuld Skolerapport for Hunderupskolen, i Odense kommune, for skoleår 2013/2014 for klassetrin(ene) 7. med reference Tilsvarende klassetrin i kommunen

Side 1 af 43 Side 2 af 43 Side 3 af 43 Side 4 af 43 Side 5 af 43 Side 6 af 43 Side 7 af 43 Side 8 af 43 Side 9 af 43 Side 10 af 43 Side 11 af 43 Side 12 af 43 Side 13 af 43 Side 14 af 43 Side 15 af 43

### 9 Matrices, determinants, inverse matrix, Cramer s Rule

AAC - Business Mathematics I Lecture #9, December 15, 2007 Katarína Kálovcová 9 Matrices, determinants, inverse matrix, Cramer s Rule Basic properties of matrices: Example: Addition properties: Associative:

### SQL Queries. CS 377: Database Systems

SQL Queries CS 377: Database Systems SQL Outline Data definition Database Creation Table Creation Query (SELECT) Data update (INSERT, DELETE, UPDATE) View definition Basic SQL Retrieval Query Basic form

### SQL Server 2008 Core Skills. Gary Young 2011

SQL Server 2008 Core Skills Gary Young 2011 Confucius I hear and I forget I see and I remember I do and I understand Core Skills Syllabus Theory of relational databases SQL Server tools Getting help Data

### ACCESS CONTROL IN A RELATIONAL DATA BASE MANAGEMENT SYSTEM BY QUERY MODIFICATION

ACCESS CONTROL IN A RELATIONAL DATA BASE MANAGEMENT SYSTEM BY QUERY MODIFICATION Michael Stonebraker and Eugene Wong Department of Electrical Engineering and Computer Sciences and the Electronics Research

### Handling Missing Values in the SQL Procedure

Handling Missing Values in the SQL Procedure Danbo Yi, Abt Associates Inc., Cambridge, MA Lei Zhang, Domain Solutions Corp., Cambridge, MA ABSTRACT PROC SQL as a powerful database management tool provides