Database Redesign. 1. Additional SQL Statements 3 1) Correlated Sub-Query 3 2) EXISTS 4 3) NOT EXISTS 7 4) double NOT EXISTS (FOR ALL) 9.

Size: px
Start display at page:

Download "Database Redesign. 1. Additional SQL Statements 3 1) Correlated Sub-Query 3 2) EXISTS 4 3) NOT EXISTS 7 4) double NOT EXISTS (FOR ALL) 9."

Transcription

1 Database Redesign 1. Additional SQL Statements 3 1) Correlated Sub-Query 3 2) EXISTS 4 3) NOT EXISTS 7 4) double NOT EXISTS (FOR ALL) 9 [Report] 14

2 Additional SQL Statements (Database Redesign) What we need to learn in chapter 8 1. Database Redesign 2. Additional SQL Statement - Exists - Not Exists 3. Analyzing the Existing Database 4. Changing Table Names and Table Columns 5. Changing Relationship Cardinalities and Properties

3 1. Additional SQL Statements 1) Correlated Sub-Query The following correlated subquery can be used to check for any rows that violate the functional dependency Department BudgetCode SELECT FROM WHERE E1.Department, E1.BudgetCode EMPLOYEE E1 E1.Department IN (SELECT E2.Department FROM EMPLOYEE E2 WHERE E1.Department = E2.Department AND E1.BudgetCode <> E2.BudgetCode); E1 E2

4 2) EXISTS SELECT FROM WHERE E1.Department, E1.BudgetCode EMPLOYEE E1 EXISTS (SELECT * FROM EMPLOYEE E2 WHERE E1.Department = E2.Department AND E1.BudgetCode <> E2.BudgetCode); (EX) x = 1, 5, 10 y = 5, 10, 15 Find an integer x such that there exists an integer y such that x > y y ( x > y )

5 S P S# S2 S3 S5 P# P1 P3 P4 P5 P6 SNAME Smith Jones Blakes Clark Adams PNAME Nut Bolt Screw Screw Cam Cog STATUS COLOR Red Green Blue Red Blue Red CITY London Paris Paris London Athenes WEIGHT CITY London Paris Rome London Paris London SP S# S2 S2 S3 P# P1 P3 P4 P5 P6 P1 P4 P5 QTY 부품번호가 p2" 인부품을공급하는공급자이름을구하시오 SELECT DISTINCT S.SNAME FROM S WHERE EXISTS ( SELECT * FROM SP WHERE SP.S# = S.S# AND SP.P# = '' ) ; Find a S such that there exists a SP such that (SP.S# = S.S# and SP.P#='') Find a S such that sp, (SP.S# = S.S# and SP.P#='') is equal to SELECT DISTINCT S.SNAME FROM S WHERE S.S# IN ( SELECT SP.S# FROM SP WHERE SP.P# = '' ) ; is equal to SELECT DISTINCT S.SNAME FROM S, SP WHERE SP.S# = S.S# AND SP.P# = '' ) ;

6 -- By C program #include <stdio.h> #define SMAX 5 #define PMAX 6 #define SPMAX 12 int S[SMAX] = 1, 2, 3, 4, 5; int SP[SPMAX][2] = 1,1, 1,2, 1,3, 1,4, 1,5, 1,6, 2,1, 2,2, 3,2, 4,2, 4,4, 4,5 ; main() int i,j,k; for(i=0; i<smax; i++) for(k=0; k<spmax; k++) if ( ( S[i] == SP[k][0] ) && ( SP[k][1] == 2 ) ) printf(" S : %5d \n", S[i]); continue;

7 3) NOT EXISTS 부품번호 p2" 를공급하지않는공급자이름을구하시오 SELECT DISTINCT S.SNAME FROM S WHERE NOT EXISTS ( SELECT * FROM SP WHERE SP.S# = S.S# AND SP.P# = '' ) ; is equal to SELECT DISTINCT S.SNAME FROM S WHERE S.S# NOT IN (SELECT SP.S# FROM SP WHERE SP.P# = '' ) ; S S# S2 S3 S5 SNAME Smith Jones Blakes Clark Adams STATUS CITY London Paris Paris London Athenes SP S# S2 S2 S3 P# P1 P3 P4 P5 P6 P1 P4 P5 QTY

8 -- #include <stdio.h> #define SMAX 5 #define PMAX 6 #define SPMAX 12 int S[SMAX] = 1, 2, 3, 4, 5; int SP[SPMAX][2] = 1,1, 1,2, 1,3, 1,4, 1,5, 1,6, 2,1, 2,2, 3,2, 4,2, 4,4, 4,5 ; int N_EXISTS[SMAX] = 0 ; main() int i,j,k; int NOTEXISTS = 1; for(i=0; i<smax; i++) for(k=0; k<spmax; k++) if ( ( S[i] == SP[k][0] ) && ( SP[k][1] == 2 ) ) printf(" S : %5d \n", S[i]); NOTEXISTS = 0 ; continue; if ( NOTEXISTS ) N_EXISTS[i] = 1 ; NOTEXISTS = 1; for ( i=0; i<smax; i++) if ( N_EXISTS[i] ) printf(" Supplier : %d\n", S[i]);

9 4) double NOT EXISTS (FOR ALL) 모든부품을공급하는공급자이름을구하시오 SELECT DISTINCT S.SNAME FROM S WHERE NOT EXISTS (SELECT * FROM P WHERE NOT EXISTS (SELECT * FROM SP WHERE SP.S# = S.S# AND SP.P# = P.P# ) ) ; FORALL in terms of negated existential quantifiers FORALL x (f) = NOT EXISTS x ( NOT f) "all x's satisfy f" is the same as "no x's do not satisfy f" FORALL x ( EXIST y (y>x) = NOT EXISTS x ( NOT EXISTS y (y>x) "For all integer x, there exists an integer y such that y > x" is equivalent to the statement (EX) x = 1, 5, 10 y = 5, 10, 15 "there does not exist an integer x such that there does not exist an integer y such that y > x" FORALL P (EXIST SP (... ) = NOT EXIST P (NOT EXIST SP (... ) )

10 가. part 1 ( 공급하고있는상황에대한모든정보 ) select * from SP, s, p where s.s# = sp.s# and p.p# = sp.p# (12 개행적용됨 ) 나. part 1과같은표현 select * from s, p where EXISTS ( select * from SP where s.s# = sp.s# and p.p# = sp.p# ) ;

11 다. part 2 /* all combinations of s, sp, p that are not satisfied join condition */ ( 공급안하고있는모든상황 ) select * from s, p where NOT EXISTS ( select * from SP where s.s# = sp.s# and p.p# = sp.p# ) ; 여기에만족하는않는공급자? = select * from s where NOT EXISTS ( select * from p where NOT EXISTS ( select * from SP where s.s# = sp.s# and p.p# = sp.p# ) ) ;

12 [Program to illustrate the SQL NOT EXISTS] #include <stdio.h> #define SMAX 5 #define PMAX 6 #define SPMAX 12 int S[SMAX] = 1, 2, 3, 4, 5; int P[PMAX] = 1, 2, 3, 4, 5, 6; int SP[SPMAX][2] = 1,1, 1,2, 1,3, 1,4, 1,5, 1,6, 2,1, 2,2, 3,2, 4,2, 4,4, 4,5 ; int N_EXISTS[SMAX] = 0 ; main() int int i,j,k; NOTEXISTS=1; for(i=0; i<smax; i++) for ( j=0; j<pmax; j++) for(k=0; k<spmax; k++) if ( ( S[i] == SP[k][0] ) && ( P[j] == SP[k][1] ) ) NOTEXISTS = 0; printf("matched SP S# : %d P# : %d \n", SP[k][0], SP[k][1] ); continue; if ( NOTEXISTS ) printf(" S : %5d, P : %5d \n", S[i], P[j] ); N_EXISTS[i] = 1; /* constructing the result of PART 2 */ NOTEXISTS = 1; for ( i=0; i<smax; i++) if (! N_EXISTS[i] ) printf(" Supplier Number : %d\n", S[i] );

13 The following code determines the name of any ARTIST that is of interest to every CUSTOMER: SELECT FROM WHERE A.Name ARTIST AS A NOT EXISTS (SELECT C.CustomerID FROM CUSTOMER C WHERE NOT EXISTS (SELECT CI.CustomerID FROM CUSTOMER_artist_int CI WHERE C.CustomerID = CI.CustomerID AND A.ArtistID = CI.ArtistID));

14 [Report ] Implement the C program code such like one in page 12 corresponding to the SQL code in page 13

Structured Query Language (SQL) Part B. KSE 521 Topic 11 Mun Y. Yi

Structured Query Language (SQL) Part B. KSE 521 Topic 11 Mun Y. Yi Structured Query Language (SQL) Part B KSE 521 Topic 11 Mun Y. Yi Agenda Data Types Join On Syntax View Correlated Subquery Data Types An Example JOIN ON Syntax JOIN ON syntax: SELECT CUSTOMER.Name, ARTIST.Name

More information

Database Systems Relational Model. A.R. Hurson 323 CS Building

Database Systems Relational Model. A.R. Hurson 323 CS Building Relational Model A.R. Hurson 323 CS Building Relational data model Database is represented by a set of tables (relations), in which a row (tuple) represents an entity (object, record) and a column corresponds

More information

Unit 3 The Relational Model

Unit 3 The Relational Model Unit 3 The Relational Model 3-1 Outline 31 Introduction 32 Relational Data Structure 33 Relational Integrity Rules 34 Relational Algebra 35 Relational Calculus 3-2 31 Introduction 3-3 Relational Model

More information

Supplier-Parts-DB SNUM SNAME STATUS CITY S1 Smith 20 London S2 Jones 10 Paris S3 Blake 30 Paris S4 Clark 20 London S5 Adams 30 Athens

Supplier-Parts-DB SNUM SNAME STATUS CITY S1 Smith 20 London S2 Jones 10 Paris S3 Blake 30 Paris S4 Clark 20 London S5 Adams 30 Athens Page 1 of 27 The Relational Data Model The data structures of the relational model Attributes and domains Relation schemas and database schemas (decomposition) The universal relation schema assumption

More information

MySQL Introduction. Practical Course Integrative Bioinformatics. March 7, 2012

MySQL Introduction. Practical Course Integrative Bioinformatics. March 7, 2012 MySQL Introduction Practical Course Integrative Bioinformatics March 7, 2012 1 What is MySQL? MySQL ist the most popular open source SQL database. Originally developed by MySQL AB it is now owned by Oracle

More information

Introduction The SELECT statement: basics Nested queries Set operators Update commands Table management

Introduction The SELECT statement: basics Nested queries Set operators Update commands Table management Databases Unit 3 DB M B G Introduction The SELECT statement: basics Nested queries Set operators Update commands Table management D B M G 2 2013 Politecnico di Torino 1 Introduction DB M B G Introduction

More information

Information Systems. Relational Databases. Nikolaj Popov

Information Systems. Relational Databases. Nikolaj Popov Information Systems Relational Databases Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria popov@risc.uni-linz.ac.at Outline The Relational Model (Continues

More information

UFCEKG 20 2 : Data, Schemas and Applications

UFCEKG 20 2 : Data, Schemas and Applications Lecture 11 UFCEKG 20 2 : Data, Schemas and Applications Lecture 11 Database Theory & Practice (5) : Introduction to the Structured Query Language (SQL) Origins & history Early 1970 s IBM develops Sequel

More information

CS5300 Database Systems

CS5300 Database Systems CS5300 Database Systems Views A.R. Hurson 323 CS Building hurson@mst.edu Note, this unit will be covered in two lectures. In case you finish it earlier, then you have the following options: 1) Take the

More information

Lecture 15: Database Normalization

Lecture 15: Database Normalization Lecture 15: Database Normalization Dr Kieran T. Herley Department of Computer Science University College Cork 2018/19 KH (12/11/18) Lecture 15: Database Normalization 2018/19 1 / 18 Summary The perils

More information

A Sample Solution to the Midterm Test

A Sample Solution to the Midterm Test CS3600.1 Introduction to Database System Fall 2016 Dr. Zhizhang Shen A Sample Solution to the Midterm Test 1. A couple of W s(10) (a) Why is it the case that, by default, there are no duplicated tuples

More information

Unit 4 SQL language: other definitions

Unit 4 SQL language: other definitions Databases D B M G Unit 4 SQL language: other definitions SQL language: other definitions Transactions Use of SQL in programming languages, SQL for applications Access control Index management D B M G 2

More information

Relational Data Structure and Concepts. Structured Query Language (Part 1) The Entity Integrity Rules. Relational Data Structure and Concepts

Relational Data Structure and Concepts. Structured Query Language (Part 1) The Entity Integrity Rules. Relational Data Structure and Concepts Relational Data Structure and Concepts Structured Query Language (Part 1) Two-dimensional tables whose attributes values are atomic. At every row-and-column position within the table, there always exists

More information

3 장. Access Object - Tables are for storing data. - Queries are for retrieving data - Forms are for entering and displaying data on screen.

3 장. Access Object - Tables are for storing data. - Queries are for retrieving data - Forms are for entering and displaying data on screen. 1장 Business Intelligence (BI) is about creating intelligence about a business organization. More specifically, it refers to technologies, applications, and practices used to capture and analyze data with

More information

CS5300 Database Systems

CS5300 Database Systems CS5300 Database Systems Introduction A.R. Hurson 128 EECH Building hurson@mst.edu Instructor: Ali R. Hurson 128 EECH Building hurson@mst.edu Text: Fundamentals of Database Systems 7 th Edition (Elmasri

More information

Chapter 7 Relational Calculus

Chapter 7 Relational Calculus Chapter 7 Relational Calculus Relational algebra tells us how to construct a table, while relational calculus tells us what to get for that table. For example, consider the query Get supplier numbers and

More information

3 Data Models and Data Sublanguages

3 Data Models and Data Sublanguages 3 Data Models and Data Sublanguages 3.1 INTRODUCTION The data model and the associated data sublanguage are the basic means by which data independence is achieved: the data model (DM) is the user's view

More information

CHAPTER 5 SECURITY ADVANCED DATABASE SYSTEMS. Assist. Prof. Dr. Volkan TUNALI

CHAPTER 5 SECURITY ADVANCED DATABASE SYSTEMS. Assist. Prof. Dr. Volkan TUNALI CHAPTER 5 SECURITY ADVANCED DATABASE SYSTEMS Assist. Prof. Dr. Volkan TUNALI Topics 2 Introduction Discretionary Access Control Mandatory Access Control Statistical Databases Data Encryption SQL Facilities

More information

The Relational Model and Normalization

The Relational Model and Normalization The Relational Model and Normalization 1. Introduction 2 2. Relational Model Terminology 3 4. Normal Forms 11 5. Multi-valued Dependency 21 6. The Fifth Normal Form 22 The Relational Model and Normalization

More information

LABSHEET 1: creating a table, primary keys and data types

LABSHEET 1: creating a table, primary keys and data types LABSHEET 1: creating a table, primary keys and data types Before you begin, you may want to take a look at the following links to remind yourself of the basics of MySQL and the SQL language. MySQL 5.7

More information

Deriving Conceptual Schema from XML Databases

Deriving Conceptual Schema from XML Databases Deriving Conceptual Schema from XML Databases Oviliani Yenty Yuliana, Suphamit Chittayasothorn 2 Department of Informatics Engineering, Petra Christian University, Surabaya, Indonesia 2 Faculty of Engineering,

More information

Chapter 8 INTEGRITY 1

Chapter 8 INTEGRITY 1 Chapter 8 INTEGRITY 1 Introduction Integrity refers to the correctness or accuracy of data in the database For examples: In Supplier-Part-Project database, the status values might have to be in the range

More information

Stored and Inherited Relations for SQL Databases

Stored and Inherited Relations for SQL Databases Stored and Inherited Relations for SQL Databases Witold Litwin 1 (March 2016) 2 Abstract. A stored and inherited relation (SIR) is a stored relation (SR) with additional inherited attributes (IAs), calculated

More information

Birkbeck. (University of London) BSc/FD EXAMINATION. Department of Computer Science and Information Systems. Database Management (COIY028H6)

Birkbeck. (University of London) BSc/FD EXAMINATION. Department of Computer Science and Information Systems. Database Management (COIY028H6) Birkbeck (University of London) BSc/FD EXAMINATION Department of Computer Science and Information Systems Database Management (COIY028H6) CREDIT VALUE: 15 credits Date of examination: 9 June 2016 Duration

More information

WEEK 3. EE562 Slides and Modified Slides from Database Management Systems, R.Ramakrishnan 1

WEEK 3. EE562 Slides and Modified Slides from Database Management Systems, R.Ramakrishnan 1 WEEK 3 EE562 Slides and Modified Slides from Database Management Systems, R.Ramakrishnan 1 Find names of parts supplied by supplier S1 (Book Notation) (using JOIN) SP JOIN P WHERE S# = S1 {PNAME} (SP WHERE

More information

2. Software Oracle 12c is installed on departmental server machines.

2. Software Oracle 12c is installed on departmental server machines. 1. Introduction This note describes how to access the Oracle database management system on the departmental computer systems. Basic information on the use of SQL*Plus is included. Section 8 tells you how

More information

Database Systems External Sorting and Query Optimization. A.R. Hurson 323 CS Building

Database Systems External Sorting and Query Optimization. A.R. Hurson 323 CS Building External Sorting and Query Optimization A.R. Hurson 323 CS Building External sorting When data to be sorted cannot fit into available main memory, external sorting algorithm must be applied. Naturally,

More information

Elena Baralis and Tania Cerquitelli 2013 Politecnico di Torino 1

Elena Baralis and Tania Cerquitelli 2013 Politecnico di Torino 1 Introduction The INSERT command The DELETE command The UPDATE command SQL language: basics D B M G 2 (1/3) Inserting tuples Deleting tuples Modifying tuples Introduction D B M G 4 (2/3) INSERT inserting

More information

D B M G. SQL language: basics. Managing tables. Creating a table Modifying table structure Deleting a table The data dictionary Data integrity

D B M G. SQL language: basics. Managing tables. Creating a table Modifying table structure Deleting a table The data dictionary Data integrity SQL language: basics Creating a table Modifying table structure Deleting a table The data dictionary Data integrity 2013 Politecnico di Torino 1 Creating a table Creating a table (1/3) The following SQL

More information

CSE 344 JANUARY 19 TH SUBQUERIES 2 AND RELATIONAL ALGEBRA

CSE 344 JANUARY 19 TH SUBQUERIES 2 AND RELATIONAL ALGEBRA CSE 344 JANUARY 19 TH SUBQUERIES 2 AND RELATIONAL ALGEBRA ASSORTED MINUTIAE Winter storm Inga Online quiz out after class Still due Wednesday, will be shorter but through today s lecture For SQLite submissions,

More information

T h e M u l t i r e l a t i o n a l A p p r o a c h

T h e M u l t i r e l a t i o n a l A p p r o a c h Chapter 24 T h e M u l t i r e l a t i o n a l A p p r o a c h Do I contradict myself? Very well then I contradict myself, (I am large, I contain multitudes.) Walt Whitman: Song of Myself If we had some

More information

D B M G 2. SQL language: basics. Update commands. Introduction The INSERT command The DELETE command The UPDATE command

D B M G 2. SQL language: basics. Update commands. Introduction The INSERT command The DELETE command The UPDATE command SQL language: basics DB M B G Introduction The INSERT command The DELETE command The UPDATE command D B M G 2 2013 Politecnico di Torino 1 Introduction DB M B G (1/3) Inserting tuples Deleting tuples Modifying

More information

Table : Purchase. Field DataType Size Constraints CustID CHAR 5 Primary key CustName Varchar 30 ItemName Varchar 30 PurchaseDate Date

Table : Purchase. Field DataType Size Constraints CustID CHAR 5 Primary key CustName Varchar 30 ItemName Varchar 30 PurchaseDate Date Q1. Write SQL query for the following : (i) To create above table as per specification given (ii) To insert 02 records as per your choice (iii) Display the Item name, qty & s of all items purchased by

More information

U1. Data Base Management System (DBMS) Unit -1. MCA 203, Data Base Management System

U1. Data Base Management System (DBMS) Unit -1. MCA 203, Data Base Management System Data Base Management System (DBMS) Unit -1 New Delhi-63,By Vaibhav Singhal, Asst. Professor U2.1 1 Data Base Management System Data: Data is the basic raw,fact and figures Ex: a name, a digit, a picture

More information

Data Retrieval Language (2)

Data Retrieval Language (2) Data Retrieval Language (2) 1 Self-join Queries 2 Sample database EMPLOYEE e# name manager# e# name manager# --------------------- 10 John NULL 20 Peter 10 30 Mary 10 40 Mike 20 50 Kate 20 60 Greg 50 70

More information

Database Systems CSE 414

Database Systems CSE 414 Database Systems CSE 414 Lecture 6: Nested Queries in SQL 1 Announcements WQ2 is due on Sunday 11pm no late days HW2 is due on Tuesday 11pm 2 Lecture Goals Today we will learn how to write (even) more

More information

CS2 Current Technologies Lecture 3: SQL - Joins and Subqueries

CS2 Current Technologies Lecture 3: SQL - Joins and Subqueries T E H U N I V E R S I T Y O H F R G E D I N B U CS2 Current Technologies Lecture 3: SQL - Joins and Subqueries Chris Walton (cdw@dcs.ed.ac.uk) 11 February 2002 Multiple Tables 1 Redundancy requires excess

More information

Principles of LDAP Schema Design

Principles of LDAP Schema Design 04-P2006 1/10/02 12:12 PM Page 55 F O U R Principles of LDAP Schema Design CHAPTER OBJECTIVES Typical Problems with LDAP Schema Design... 59 An Example... 66 Summary... 72 An LDAP accessible Directory

More information

12. MS Access Tables, Relationships, and Queries

12. MS Access Tables, Relationships, and Queries 12. MS Access Tables, Relationships, and Queries 12.1 Creating Tables and Relationships Suppose we want to build a database to hold the information for computers (also refer to parts in the text) and suppliers

More information

Database Applications (15-415)

Database Applications (15-415) Database Applications (15-415) The Relational Model Lecture 3, January 18, 2015 Mohammad Hammoud Today Last Session: The entity relationship (ER) model Today s Session: ER model (Cont d): conceptual design

More information

Sankalchand Patel College of Engineering, Visnagar B.E. Semester III (CE/IT) Database Management System Question Bank / Assignment

Sankalchand Patel College of Engineering, Visnagar B.E. Semester III (CE/IT) Database Management System Question Bank / Assignment Sankalchand Patel College of Engineering, Visnagar B.E. Semester III (CE/IT) Database Management System Question Bank / Assignment Introductory concepts of DBMS 1. Explain detailed 3-level architecture

More information

Review: Where have we been?

Review: Where have we been? SQL Basic Review Query languages provide 2 key advantages: Less work for user asking query More opportunities for optimization Algebra and safe calculus are simple and powerful models for query languages

More information

Lesson 2. Data Manipulation Language

Lesson 2. Data Manipulation Language Lesson 2 Data Manipulation Language IN THIS LESSON YOU WILL LEARN To add data to the database. To remove data. To update existing data. To retrieve the information from the database that fulfil the stablished

More information

Full file at

Full file at David Kroenke's Database Processing: Fundamentals, Design and Implementation (10 th Edition) CHAPTER TWO INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) True-False Questions 1. SQL stands for Standard

More information

Querying Data with Transact SQL

Querying Data with Transact SQL Course 20761A: Querying Data with Transact SQL Course details Course Outline Module 1: Introduction to Microsoft SQL Server 2016 This module introduces SQL Server, the versions of SQL Server, including

More information

-- Jerad Godsave -- November 9, CIS Assignment A8.sql

-- Jerad Godsave -- November 9, CIS Assignment A8.sql -- Jerad Godsave -- November 9, 2015 -- CIS 310-01 4158 -- Assignment A8.sql -- 1. List the products with a list price greater than the average list price of all products. -- result set: ItemID

More information

Structured Query Language (SQL) Advanced Features

Structured Query Language (SQL) Advanced Features Explicit Joins Structured Query Language (SQL) Advanced Features Joins are usually specified as part of the WHERE statement (implicit or innerjoins.) Further, LEFT, RIGHT, and FULL OUTER joins can also

More information

Keys, SQL, and Views CMPSCI 645

Keys, SQL, and Views CMPSCI 645 Keys, SQL, and Views CMPSCI 645 SQL Overview SQL Preliminaries Integrity constraints Query capabilities SELECT-FROM- WHERE blocks, Basic features, ordering, duplicates Set ops (union, intersect, except)

More information

The Relational Model

The Relational Model The Relational Model UVic C SC 370, Fall 2002 Daniel M. German Department of Computer Science University of Victoria 3 1 The Relational Model CSC 370 dmgerman@uvic.ca Overview How is data represented in

More information

Introduction SQL DRL. Parts of SQL. SQL: Structured Query Language Previous name was SEQUEL Standardized query language for relational DBMS:

Introduction SQL DRL. Parts of SQL. SQL: Structured Query Language Previous name was SEQUEL Standardized query language for relational DBMS: Introduction SQL: Structured Query Language Previous name was SEQUEL Standardized query language for relational DBMS: SQL The standard is evolving over time SQL-89 SQL-9 SQL-99 SQL-0 SQL is a declarative

More information

NURSING_STAFF NNbr NName Grade

NURSING_STAFF NNbr NName Grade The SELECT command is used to indicate which information we need to obtain not how the information is to be processed. SQL is a non-procedural language. SELECT [DISTINCT ALL] {* [column_expression [AS

More information

LAB 3 Part 1 ADBC - Interactive SQL Queries-Advanced

LAB 3 Part 1 ADBC - Interactive SQL Queries-Advanced LAB 3 Part 1 ADBC - Interactive SQL Queries-Advanced ***For each question Create the SQL query that solves the problem Write all SQL statements in the same script file and save into a text file called

More information

King Fahd University of Petroleum and Minerals

King Fahd University of Petroleum and Minerals 1 King Fahd University of Petroleum and Minerals Information and Computer Science Department ICS 334: Database Systems Semester 041 Major Exam 1 18% ID: Name: Section: Grades Section Max Scored A 5 B 25

More information

CIS 330: Applied Database Systems

CIS 330: Applied Database Systems 1 CIS 330: Applied Database Systems Lecture 7: SQL Johannes Gehrke johannes@cs.cornell.edu http://www.cs.cornell.edu/johannes Logistics Office hours role call: Mondays, 3-4pm Tuesdays, 4:30-5:30 Wednesdays,

More information

Dr. Lyn Mathis Page 1

Dr. Lyn Mathis Page 1 CSIS 3222, Fall 2008, Chapter 1, 3, 4, 5 (through p. 128) Name (Six Pages) Part I: MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. (3 points each)

More information

CS2 Current Technologies Lecture 2: SQL Programming Basics

CS2 Current Technologies Lecture 2: SQL Programming Basics T E H U N I V E R S I T Y O H F R G E D I N B U CS2 Current Technologies Lecture 2: SQL Programming Basics Dr Chris Walton (cdw@dcs.ed.ac.uk) 4 February 2002 The SQL Language 1 Structured Query Language

More information

2) SQL includes a data definition language, a data manipulation language, and SQL/Persistent stored modules. Answer: TRUE Diff: 2 Page Ref: 36

2) SQL includes a data definition language, a data manipulation language, and SQL/Persistent stored modules. Answer: TRUE Diff: 2 Page Ref: 36 Database Processing, 12e (Kroenke/Auer) Chapter 2: Introduction to Structured Query Language (SQL) 1) SQL stands for Standard Query Language. Diff: 1 Page Ref: 32 2) SQL includes a data definition language,

More information

Multiple-Choice. 3. When you want to see all of the awards, even those not yet granted to a student, replace JOIN in the following

Multiple-Choice. 3. When you want to see all of the awards, even those not yet granted to a student, replace JOIN in the following Database Design, CSCI 340, Spring 2015 Final, May 12 Multiple-Choice 1. Which of the following is not part of the vocabulary of database keys? (3 pts.) a. Referential key b. Composite key c. Primary key

More information

SQL Lab Query 5. More SQL Aggregate Queries, Null Values. SQL Lab Query 8. SQL Lab Query 5. SQL Lab Query 8. SQL Lab Query 9

SQL Lab Query 5. More SQL Aggregate Queries, Null Values. SQL Lab Query 8. SQL Lab Query 5. SQL Lab Query 8. SQL Lab Query 9 SQL Lab Query 5 Sailors sid sname rating age Reserves sid bid day Boats bid name color More SQL Aggregate Queries, Null Values Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke

More information

V. Database Design CS448/ How to obtain a good relational database schema

V. Database Design CS448/ How to obtain a good relational database schema V. How to obtain a good relational database schema Deriving new relational schema from ER-diagrams Normal forms: use of constraints in evaluating existing relational schema CS448/648 1 Translating an E-R

More information

More on SQL Nested Queries Aggregate operators and Nulls

More on SQL Nested Queries Aggregate operators and Nulls Today s Lecture More on SQL Nested Queries Aggregate operators and Nulls Winter 2003 R ecom m en ded R eadi n g s Chapter 5 Section 5.4-5.6 http://philip.greenspun.com/sql/ Simple queries, more complex

More information

Further GroupBy & Extend Operations

Further GroupBy & Extend Operations Slide 1 Further GroupBy & Extend Operations Objectives of the Lecture : To consider whole relation Grouping; To consider the SQL Grouping option Having; To consider the Extend operator & its implementation

More information

Lassonde School of Engineering Winter 2016 Term Course No: 4411 Database Management Systems

Lassonde School of Engineering Winter 2016 Term Course No: 4411 Database Management Systems Lassonde School of Engineering Winter 2016 Term Course No: 4411 Database Management Systems Last Name: First Name: Student ID: 1. Exam is 2 hours long 2. Closed books/notes Problem 1 (6 points) Consider

More information

Programming By Contract: Designing for Correctness

Programming By Contract: Designing for Correctness Programming By Contract: Designing for Correctness James C. McKim, Jr. Rensselaer, 1999 1 of 20 Overview What is Programming by Contract? How do we use Programming by Contract to design correct classes?

More information

The Relational Model. Chapter 3

The Relational Model. Chapter 3 The Relational Model Chapter 3 Why Study the Relational Model? Most widely used model. Systems: IBM DB2, Informix, Microsoft (Access and SQL Server), Oracle, Sybase, MySQL, etc. Legacy systems in older

More information

Teradata SQL Features Overview Version

Teradata SQL Features Overview Version Table of Contents Teradata SQL Features Overview Version 14.10.0 Module 0 - Introduction Course Objectives... 0-4 Course Description... 0-6 Course Content... 0-8 Module 1 - Teradata Studio Features Optimize

More information

The Relational Model. Chapter 3. Database Management Systems, R. Ramakrishnan and J. Gehrke 1

The Relational Model. Chapter 3. Database Management Systems, R. Ramakrishnan and J. Gehrke 1 The Relational Model Chapter 3 Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc.

More information

Introduction to Data Management. Lecture 16 (SQL: There s STILL More...) It s time for another installment of...

Introduction to Data Management. Lecture 16 (SQL: There s STILL More...) It s time for another installment of... Introduction to Data Management Lecture 16 (SQL: There s STILL More...) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 It s time for another

More information

Database Applications (15-415)

Database Applications (15-415) Database Applications (15-415) SQL-Part II Lecture 8, February 2, 2016 Mohammad Hammoud Today Last Session: Standard Query Language (SQL)- Part I Today s Session: Standard Query Language (SQL)- Part II

More information

DATABASE CONCEPTS. Dr. Awad Khalil Computer Science & Engineering Department AUC

DATABASE CONCEPTS. Dr. Awad Khalil Computer Science & Engineering Department AUC DATABASE CONCEPTS Dr. Awad Khalil Computer Science & Engineering Department AUC s are considered as major components in almost all recent computer application systems, including business, management, engineering,

More information

Lab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama

Lab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama The Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Database Lab Lab # 6 Using Subqueries and Set Operators Eng. Alaa O Shama November, 2015 Objectives:

More information

CPS510 Database System Design Primitive SYSTEM STRUCTURE

CPS510 Database System Design Primitive SYSTEM STRUCTURE CPS510 Database System Design Primitive SYSTEM STRUCTURE Naïve Users Application Programmers Sophisticated Users Database Administrator DBA Users Application Interfaces Application Programs Query Data

More information

Database Management Systems

Database Management Systems ADIKAVI NANNAYA UNIVERSITY CBCS/SEMESTER SYSTEM IV SEMESTER BACHELOR OF COMPUTER APPLICATIONS (w.e.f. 2015-16 Admitted Batch) Database Management Systems Unit-I: Database Systems Introduction and Fundamentals:

More information

Objectives. After completing this lesson, you should be able to do the following:

Objectives. After completing this lesson, you should be able to do the following: Objectives After completing this lesson, you should be able to do the following: Describe the types of problems that subqueries can solve Define subqueries List the types of subqueries Write single-row

More information

Lecture 2 SQL. Instructor: Sudeepa Roy. CompSci 516: Data Intensive Computing Systems

Lecture 2 SQL. Instructor: Sudeepa Roy. CompSci 516: Data Intensive Computing Systems CompSci 516 Data Intensive Computing Systems Lecture 2 SQL Instructor: Sudeepa Roy Duke CS, Spring 2016 CompSci 516: Data Intensive Computing Systems 1 Announcement If you are enrolled to the class, but

More information

SQL from Applications

SQL from Applications SQL from Applications UVic C SC 370 Dr. Daniel M. German Department of Computer Science June 4, 2003 Version: 1.1.0 6 1 SQL from Applications (1.1.0) CSC 370 dmgerman@uvic.ca Overview Embedded SQL JDBC

More information

Introduction to Database Systems CSE 414

Introduction to Database Systems CSE 414 Introduction to Database Systems CSE 414 Lecture 8: Nested Queries in SQL CSE 414 - Spring 2013 1 Announcements Homework 2 due tonight Webquiz 3 due Friday 2 questions on nested queries (i.e., today s

More information

Overview. SQL from Applications. Accesing data from an application. Embedded SQL JDBC Stored Procedures. UVic C SC 370, Fall 2002

Overview. SQL from Applications. Accesing data from an application. Embedded SQL JDBC Stored Procedures. UVic C SC 370, Fall 2002 SQL from Applications UVic C SC 370, Fall 2002 Embedded SQL JDBC Stored Procedures Overview Daniel M. German Department of Computer Science University of Victoria October 15, 2002 Version: 1.00 6 1 SQL

More information

Unit 14 Security and Integrity

Unit 14 Security and Integrity Unit 14 Security and Integrity 14-1 Contents 14.1 Introduction 14.2 Security 14.3 Integrity 14.4 Security and Integrity in INGRES 14.5 Security in Statistical Databases user 14.6 Data Encryption DBMS user

More information

SQL: The Query Language Part 1. Relational Query Languages

SQL: The Query Language Part 1. Relational Query Languages SQL: The Query Language Part 1 CS 186, Fall 2002, Lecture 9 R &G - Chapter 5 Life is just a bowl of queries. -Anon (not Forrest Gump) Relational Query Languages A major strength of the relational model:

More information

Test Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke

Test Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke Test Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke Link full download: https://testbankservice.com/download/test-bank-fordatabase-processing-fundamentals-design-and-implementation-13th-edition-bykroenke

More information

Introduction to Data Management. Lecture #4 (E-R Relational Translation)

Introduction to Data Management. Lecture #4 (E-R Relational Translation) Introduction to Data Management Lecture #4 (E-R Relational Translation) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v Today

More information

HIERARCHICAL MODEL. Project E_nm

HIERARCHICAL MODEL. Project E_nm HIERARCHICAL MODEL Main data structuring concepts: record type and one-to-many parent-child relationships (PCR) The hierarchical database schema consists of a number of hierarchical schemas or hierarchies.

More information

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

The Relational Model. Why Study the Relational Model? Relational Database: Definitions The Relational Model Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Microsoft, Oracle, Sybase, etc. Legacy systems in

More information

Temporal Databases. Week 8. (Chapter 22 & Notes)

Temporal Databases. Week 8. (Chapter 22 & Notes) Temporal Databases Week 8 (Chapter 22 & Notes) 1 Introduction Temporal database contains historical,timevarying as well as current data. Note: historical record is a misleading term - a temporal database

More information

Detailed Data Modelling: Attribute Collection and Normalisation of Data

Detailed Data Modelling: Attribute Collection and Normalisation of Data Detailed Data Modelling IMS1002 /CSE1205 Systems Analysis and Design Detailed Data Modelling: Attribute Collection and Normalisation of Data The objective of detailed data modelling is to develop a detailed

More information

Relational Databases

Relational Databases Relational Databases Lecture 2 Chapter 3 Robb T. Koether Hampden-Sydney College Fri, Jan 18, 2013 Robb T. Koether (Hampden-Sydney College) Relational Databases Fri, Jan 18, 2013 1 / 26 1 Types of Databases

More information

Introduction to Data Management. Lecture #17 (SQL, the Never Ending Story )

Introduction to Data Management. Lecture #17 (SQL, the Never Ending Story ) Introduction to Data Management Lecture #17 (SQL, the Never Ending Story ) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v HW

More information

CHAPTER 4 MISSING INFORMATION ADVANCED DATABASE SYSTEMS. Assist. Prof. Dr. Volkan TUNALI

CHAPTER 4 MISSING INFORMATION ADVANCED DATABASE SYSTEMS. Assist. Prof. Dr. Volkan TUNALI CHAPTER 4 MISSING INFORMATION ADVANCED DATABASE SYSTEMS Assist. Prof. Dr. Volkan TUNALI Topics 2 Introduction The 3VL Approach NULLs and Keys Outer Join SQL Facilities Introduction 3 Information is often

More information

CSEN 501 CSEN501 - Databases I

CSEN 501 CSEN501 - Databases I CSEN501 - Databases I Lecture 5: Structured Query Language (SQL) Prof. Dr. Slim slim.abdennadher@guc.edu.eg German University Cairo, Faculty of Media Engineering and Technology Structured Query Language:

More information

Introduction. Sample Database SQL-92. Sample Data. Sample Data. Chapter 6 Introduction to Structured Query Language (SQL)

Introduction. Sample Database SQL-92. Sample Data. Sample Data. Chapter 6 Introduction to Structured Query Language (SQL) Chapter 6 Introduction to Structured Query Language (SQL) Introduction Structured Query Language (SQL) is a data sublanguage that has constructs for defining and processing a database It can be Used stand-alone

More information

Intro to Structured Query Language Part I

Intro to Structured Query Language Part I Intro to Structured Query Language Part I The Select Statement In a relational database, data is stored in tables. An example table would relate Social Security Number, Name, and Address: EmployeeAddressTable

More information

SQL: Queries, Constraints, Triggers (iii)

SQL: Queries, Constraints, Triggers (iii) ICS 321 Fall 2009 SQL: Queries, Constraints, Triggers (iii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 9/24/2009 Lipyeow Lim -- University of Hawaii

More information

INF 212 ANALYSIS OF PROG. LANGS SQL AND SPREADSHEETS. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS SQL AND SPREADSHEETS. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS SQL AND SPREADSHEETS Instructors: Crista Lopes Copyright Instructors. Data-Centric Programming Focus on data Interactive data: SQL Dataflow: Spreadsheets Dataflow: Iterators,

More information

Introduction to Programming. Lecture 2: Introduction to C

Introduction to Programming. Lecture 2: Introduction to C Introduction to Programming Lecture 2: Introduction to C Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Review Lecture 1 Introduction to the course General information Syllabus Course organization General rules

More information

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Thursday 16th January 2014 Time: 09:45-11:45. Please answer BOTH Questions

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Thursday 16th January 2014 Time: 09:45-11:45. Please answer BOTH Questions Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE Advanced Database Management Systems Date: Thursday 16th January 2014 Time: 09:45-11:45 Please answer BOTH Questions This is a CLOSED book

More information

Section I : Section II : Question 1. Question 2. Question 3.

Section I : Section II : Question 1. Question 2. Question 3. Computer Science, 60-415 Midterm Examiner: Ritu Chaturvedi Date: Oct. 27 th, 2011 Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) Examination Period is 1 hour and 15 minutes Answer all

More information

AMCAT Automata Coding Sample Questions And Answers

AMCAT Automata Coding Sample Questions And Answers 1) Find the syntax error in the below code without modifying the logic. #include int main() float x = 1.1; switch (x) case 1: printf( Choice is 1 ); default: printf( Invalid choice ); return

More information

ommhmhmhhhhhhlm mmhhmhmmhum

ommhmhmhhhhhhlm mmhhmhmmhum AD-AI51 581 DESIGN AND ANALYSIS OF A COMPLETE RELATIONAL INTERFA-CU 17 FOR A MULTI-BACKEND DATABASE SYSTEM(U) NAVAL POSTGRADUATE SCHOOL MONTEREY CA R E ROLLINS JUN 84 UNCLASSIFIED F/6 912 ommhmhmhhhhhhlm

More information

Database Management Systems,

Database Management Systems, Database Management Systems SQL Query Language (2) 1 Topics Update Query Delete Query Integrity Constraint Cascade Deletes Deleting a Table Join in Queries Table variables More Options in Select Queries

More information