Assignment 6: SQL III Solution

Size: px
Start display at page:

Download "Assignment 6: SQL III Solution"

Transcription

1 Data Modelling and Databases Exercise dates: April 12/April 13, 2018 Ce Zhang, Gustavo Alonso Last update: April 16, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 6: SQL III Solution This assignment will be discussed during the exercise slots indicated above. If you want feedback for your copy, hand it in during the lecture on the Wednesday before (preferably stapled and with your address. You can also annotate your copy with questions you think should be discussed during the exercise session. If you have questions that are not answered by the solution we provide, send them to Sabir This exercise sheet builds on the previous ones and it uses the Employees, ZVV and TPC-H schema and data which you can find on the course website. 1 Arrival times (ZVV The following queries can be executed on the ZVV schema. All queries are valid and return some result. What do they compute and which are equivalent? Two queries are equivalent if they return the same set of results for any data that the database may contain. 1. SELECT arrival_ time FROM stop_ times ORDER BY arrival_ time DESC LIMIT 1 2. SELECT MAX ( arrival_ time FROM stop_ times JOIN trips USING ( trip_id 4. SELECT MAX ( arrival_ time AS arrival_ time FROM stop_ times st JOIN trips t USING ( trip_id GROUP BY t. trip_id ORDER BY arrival_ time DESC LIMIT 1 3. SELECT MAX ( arrival_ time FROM stop_ times GROUP BY trip_id

2 Queries 1, 2 and 4 are equivalent and return the maximum arrival time in the database. Query 3 returns the maximum arrival time per trip. 2 Trip count (ZVV Repeat the task from question 1 for the following queries: 1. SELECT COUNT (* FROM trips 2. SELECT COUNT (* FROM trips t JOIN stop_ times st USING ( trip_id 3. SELECT COUNT (* FROM stop_ times GROUP BY trip_id 5. SELECT SUM ( vala FROM ( SELECT stop_name, COUNT (* AS vala FROM stop_ times JOIN stops USING ( stop_id GROUP BY stop_ name taba 6. SELECT COUNT ( DISTINCT trip_id FROM stop_ times 4. SELECT COUNT (* FROM trips JOIN stop_ times USING ( trip_id JOIN stops USING ( stop_id WHERE stop_ name LIKE '%' Queries 1 and 6 return the number of trips in the database and the number of trips having at least one stop. They are not equivalent, unless assumed that every trip has at least one stop, which is reasonable but technically not enforced by the schema. Queries 2, 4 and 5 are equivalent and return the number of stops in the database. The WHERE predicate in query 4 evaluates to true for all non-null values, which is guaranteed by the schema for stop_name. Query 3 returns the number of stops per trip.

3 3 Tram tracks and terminals (ZVV 1. A tram track is defined as a tuple of two consecutive stops (stop_name 1, stop_name 2. Two stops are consecutive, if there is a trip (trip_id which contains both stops and in which their stop_sequence numbers differ by 1: stop_sequence stop_name2 = 1 + stop_sequence stop_name1 Fill in the blanks below to obtain a SQL query that finds the number of trips for each tram track and lists the 10 most frequented ones. SELECT s1. stop_name, s2. stop_name, COUNT (* AS tcount FROM stop_ times st1, stop_ times st2, stops s1, stops s2 WHERE st1.trip_id = st2.trip_id AND st1.stop_sequence + 1 = st2.stop_sequence AND s1. stop_id = st1. stop_id AND s2. stop_id = st2. stop_id GROUP BY s1.stop_name, s2.stop_name ORDER BY tcount DESC LIMIT A tram stop (stop_name is terminal if it is the last stop for any trip (as identified through the trip_id. The last stop of a trip can be identified by its stop_sequence. For example, if a tram makes a trip along six tram stops, stop_sequence = 6 identifies the last stop of the trip. Fill in the blanks below to obtain an SQL query that finds all terminal tram stops (stop_name. Also make sure the result does not contain duplicate entries. SELECT DISTINCT stop_name FROM stops s JOIN stop_ times st1 USING ( stop_id, ( SELECT trip_id, MAX(stop_sequence AS maxstop FROM stop_times GROUP BY trip_id st2 WHERE st1.trip_id = st2.trip_id AND st1.stop_sequence = st2.maxstop Knowing the database schema, how else could we formulate the previous query? Compare the results. SELECT DISTINCT trip_ headsign FROM trips ;

4 4 Union (TPC-H Reminder: In the TPC-H schema, one part can be provided by multiple suppliers. Supplypart relation stores this connection and (partid, supplierid is its key. Given the following queries: 1. SELECT p. partid, p. partname FROM Part p JOIN Supplypart sp ON sp. partid = p. partid WHERE sp. supplierid = 6 OR sp. supplierid = ( SELECT p. partid, p. partname FROM Part p JOIN Supplypart sp ON sp. partid = p. partid WHERE sp. supplierid = 6 UNION ( SELECT p. partid, p. partname FROM Part p JOIN Supplypart sp ON sp. partid = p. partid WHERE sp. supplierid = What is the difference between results of the following two queries? Both queries return ids and names of parts provided by suppliers with ids 6 and 33. However, the first query doesn t return distinct results, i.e. some tuples will appear in twice. UNION, on the other hand, guarantees that all the returned rows are distinct. 2. How to quickly make the first query equivalent to the second? Use keyword DISTINCT. 3. How to quickly make the second query equivalent to the first? Replace UNION with UNION ALL. repeated. The latter returns all results, even those which are

5 5 Rewriting subquery expressions (Employees What do the following queries do? Rewrite them without using subquery expressions 1 so that they return the same results. We do not count combinations using UNION, INTERSECT and EXCEPT as subquery expressions. 1. SELECT e. emp_no, e. first_name, e. last_ name WHERE e. emp_no IN ( SELECT dm. emp_no FROM dept_ manager dm JOIN salaries s ON dm. emp_no = s. emp_no WHERE dm. to_date > NOW ( AND s. to_date > NOW ( ORDER BY s. salary DESC LIMIT 5 The query returns employee numbers, first names and last names of the top 5 currently most earning managers. This can be rewritten as: SELECT e. emp_no, e. first_name, e. last_ name JOIN dept_ manager dm ON e. emp_no = dm. emp_no JOIN salaries s ON dm. emp_no = s. emp_no WHERE dm. to_date > NOW ( AND s. to_date > NOW ( ORDER BY salary DESC LIMIT 5 Here we make an assumption that a department manager cannot appear work in several departments at the same time. Otherwise we could use the DISTINCT keyword. 2. SELECT e. emp_no, e. first_name, e. last_ name JOIN dept_ emp de ON e. emp_no = de. emp_no JOIN salaries s ON e. emp_no = s. emp_no WHERE de. to_date > NOW ( AND s. to_date > NOW ( AND s. salary > ( SELECT s1. salary FROM dept_ manager dm JOIN salaries s1 ON s1. emp_no = dm. emp_no WHERE dm. dept_no = de. dept_no AND dm. to_date > NOW ( 1

6 AND s1. to_date > NOW ( The query returns employee numbers, first names and last names of all employees currently earning more than their managers. This can be rewritten as: SELECT e. emp_no, e. first_name, e. last_ name JOIN dept_ emp de ON e. emp_no = de. emp_no JOIN dept_ manager dm ON dm. dept_no = de. dept_no JOIN salaries se ON e. emp_no = se. emp_no JOIN salaries sm ON dm. emp_no = sm. emp_no WHERE de. to_date > NOW ( AND dm. to_date > NOW ( AND se. to_date > NOW ( AND sm. to_date > NOW ( AND se. salary > sm. salary 3. SELECT e. emp_no, e. first_name, e. last_ name WHERE e. emp_no NOT IN ( SELECT dm. emp_no FROM dept_ manager dm WHERE dm. to_date > NOW ( The query returns employee numbers, first names and last names of all employees who are not managers. This can be rewritten as: ( SELECT e. emp_no, e. first_name, e. last_ name EXCEPT ( SELECT e. emp_no, e. first_name, e. last_ name JOIN dept_ manager dm ON e. emp_no = dm. emp_no WHERE dm. to_date > NOW (

7 Alternatively, we can use a LEFT OUTER JOIN, IS NULL pattern to find all employees who are not managers and allow employees who have been managers in the past. SELECT e. emp_no, e. first_name, e. last_ name LEFT OUTER JOIN dept_ manager dm USING ( emp_no WHERE dm. emp_no IS NULL OR dm. to_date < NOW (; 6 Having (Employees Write queries using the HAVING clause which do the following: 1. Find all employees who have worked in more than one department. SELECT e. first_name, e. last_ name JOIN dept_ emp de ON e. emp_no = de. emp_no GROUP BY e. emp_no HAVING COUNT ( DISTINCT dept_no > 1 2. Find names of all departments where current average salaries are higher by 5000 than in year SELECT d. dept_ name FROM dept_ emp de JOIN salaries s ON de. emp_no = s. emp_no JOIN departments d ON d. dept_no = de. dept_no WHERE s. to_date > NOW ( AND de. to_date > NOW ( GROUP BY d. dept_ name HAVING AVG ( s. salary >= ( SELECT AVG (s1. salary FROM dept_ emp de1 JOIN salaries s1 ON de1. emp_no = s1. emp_no JOIN departments d1 ON d1. dept_no = de1. dept_no WHERE d1. dept_ name = d. dept_ name AND EXTRACT ( YEAR FROM s1. to_date >= 2000 AND EXTRACT ( YEAR FROM s1. from_ date <= 2000

8 AND EXTRACT ( YEAR FROM de1. to_date >= 2000 AND EXTRACT ( YEAR FROM de1. from_ date <= 2000 AND s1. to_date >= de1. from_ date AND de1. to_date >= s1. from_ date Alternatively with a join SELECT d. dept_ name FROM dept_ emp de JOIN salaries s ON de. emp_no = s. emp_no JOIN departments d ON d. dept_no = de. dept_no JOIN dept_ emp de2000 ON de2000. dept_no = de. dept_no JOIN salaries s2000 ON s2000. emp_no = de2000. emp_no WHERE s. to_date > NOW ( AND de. to_date > NOW ( AND EXTRACT ( YEAR FROM s2000. to_date >= 2000 AND EXTRACT ( YEAR FROM s2000. from_ date <= 2000 AND EXTRACT ( YEAR FROM de2000. to_date >= 2000 AND EXTRACT ( YEAR FROM de2000. from_ date <= 2000 AND s2000. to_date >= de2000. from_ date AND de2000. to_date >= s2000. from_ date GROUP BY d. dept_ name HAVING AVG (s. salary >= AVG ( s2000. salary ; 7 Null values (Employees Warning: This part of the exercise will alter the schema and data of the employee database and might make solutions to other exercises not work as expected. To be safe, create a new database for this exercise where you reload the employee data from scratch. We will alter the schema of the employee database slightly, to explore a use for the NULL value. To be more specific, currently if an employment is open-ended in the database, the date for its end is set to year An alternative is to use a NULL value for the end date, which signifies that there is no termination decided. In our current schema we cannot add NULL to the columns, so to play around we need to first modify the schema. ALTER TABLE salaries ALTER COLUMN to_date DROP NOT NULL Now we can replace infinity dates with NULLs. UPDATE salaries SET to_date = NULL WHERE EXTRACT ( YEAR FROM to_date = 9999

9 1. Now that this is done, run the following three queries and decide which one(s correctly return(s the number of employees who received a salary in December of To receive money in a month a person has to work at least one day in that month. SELECT COUNT (* FROM salaries WHERE to_date >= ' ' SELECT COUNT (* FROM salaries WHERE from_ date <= ' ' AND to_date >= ' ' SELECT COUNT (* FROM salaries WHERE from_ date <= ' ' AND ( to_date >= ' ' OR to_date IS NULL 2. We want to find out how many contracts (entries in the Salaries table ended in each particular year. For this we wrote the following query (Q1: SELECT EXTRACT ( YEAR FROM to_date AS year_expired, COUNT (* AS num_ expired FROM salaries GROUP BY year_ expired ORDER BY year_ expired We wrote a similar query (Q2 in a more verbose way, as follows: ( SELECT EXTRACT ( YEAR FROM to_date AS year_expired, COUNT (* AS num_ expired FROM salaries WHERE EXTRACT ( YEAR FROM to_date <= 1990 GROUP BY year_ expired ORDER BY year_ expired UNION ALL ( SELECT EXTRACT ( YEAR FROM to_date AS year_expired, COUNT (* AS num_ expired FROM salaries WHERE EXTRACT ( YEAR FROM to_date > 1990 GROUP BY year_ expired ORDER BY year_ expired For this exercise try and first answer the question without using the database. Then verify your answer by running the actual queries. Which of the following statement(s are true?

10 Q1 and Q2 return the same set of groups Q1 returns more groups than Q2 Q2 returns more groups than Q1 Q1 has one group more than Q2 Q2 has one group more than Q1 8 Case (TPC-H Select queries which return correct results for the following task: Get order ids, names of customers and date labels for all orders placed in years 1995 and later. For orders from years , the date labels should say '95-97'. For orders from year 1998 and later, the labels should say '98-XX'. SELECT orderid, customername, ( CASE WHEN o. orderdate >= ' ' THEN '98 - XX ' WHEN o. orderdate >= ' ' THEN '95-97 ' END AS date_ label FROM Orders o, Customer c WHERE o. customerid = c. customerid SELECT orderid, customername, date_ label FROM ( SELECT orderid, customername, ( CASE WHEN o. orderdate >= ' ' THEN '98 - XX ' WHEN o. orderdate >= ' ' THEN '95-97 ' ELSE ' NOTHING ' END AS date_ label FROM Orders o, Customer c WHERE o. customerid = c. customerid AS labeled WHERE date_ label!= ' NOTHING ' SELECT orderid, customername, ( CASE WHEN o. orderdate >= ' ' THEN ' ' WHEN o. orderdate >= ' ' THEN '98 - XX ' END AS date_ label FROM Orders o, Customer c WHERE o. customerid = c. customerid AND o. orderdate >= ' ' SELECT orderid, customername, ( CASE WHEN o. orderdate >= ' ' THEN '98 - XX ' WHEN o. orderdate >= ' ' THEN '95-97 ' END AS date_ label FROM Orders o, Customer c WHERE o. customerid = c. customerid AND o. orderdate >= ' '

11 Explanation: 1 is incorrect because it returns all orders. For those placed before 1995, the column date_label is NULL. 3 is incorrect because the column date_label has the value '95-97' for all returned results. This is because the CASE clause works sequentially: if the first case is matched, no other cases will be checked. 9 Updatable views (Employees 1. Which of the following views are updatable? CREATE VIEW DeptManager AS SELECT e. emp_no, e. first_name, e. last_ name, dept_ manager dm WHERE e. emp_no = dm. emp_no CREATE VIEW Age AS SELECT emp_no, first_name, last_name, DATE_PART ('year ', age ( NOW (, birth_date AS age FROM employees CREATE VIEW SELECT * HiredPast97 AS FROM employees WHERE hire_ date >= ' ' CREATE VIEW DeptEmployee AS SELECT e. emp_no, e. first_name, e. last_name, d. dept_no, d. dept_ name, dept_ emp de, departments d WHERE e. emp_no = de. emp_no AND de. dept_no = d. dept_no CREATE VIEW Depts AS SELECT e. emp_no, COUNT (* AS number_ of_ depts, dept_ emp de, departments d WHERE e. emp_no = de. emp_no AND de. dept_no = d. dept_no GROUP BY e. emp_no CREATE VIEW HiredIn AS SELECT EXTRACT ( YEAR FROM hire_ date AS year_hired, COUNT (* FROM employees GROUP BY EXTRACT ( YEAR FROM hire_ date

12 Explanation: 1 and 4 are not updatable because of table joins. 2 is not updatable because of a one-way projection in the select list. 5 is not updatable because of table joins and aggregation. 6 is not updatable because of aggregation. 2. Suppose we add a new column to the employees relation: annotation of type text. ALTER TABLE employees ADD annotation TEXT Can we update it using the updatable views above? 3 can be updated only if we create the view after adding the new column. 10 Custom database Create a schema using the following commands: CREATE TABLE team ( team_id SERIAL, team_ name VARCHAR (30 NOT NULL, city_ name VARCHAR (30, PRIMARY KEY ( team_id ; CREATE TABLE referee ( referee_ id SERIAL, first_ name VARCHAR (30 NOT NULL, last_ name VARCHAR (30 NOT NULL, PRIMARY KEY ( referee_ id ; CREATE TABLE game ( game_ date DATE NOT NULL, home_ team_ id INT NOT NULL, away_ team_ id INT NOT NULL, referee_ id INT NOT NULL, PRIMARY KEY ( game_date, home_team_id, away_ team_ id ; 10.1 Altering tables 1. Add a nullable column short_name to the team relation. Its values should not be longer than 3 characters.

13 ALTER TABLE team ADD short_ name VARCHAR (3 2. Change the type of short_name to a string up to 5 characters. ALTER TABLE team ALTER short_ name TYPE VARCHAR (5 3. Remove the created column. ALTER TABLE team DROP short_ name 10.2 Data manipulation Assume that all tables are empty, i.e. the following statements have been executed: DELETE FROM team ; DELETE FROM referee ; DELETE FROM game ; Select the statements that will execute correctly on the empty database. INSERT INTO team ( team_id, team_ name VALUES (0, 'a', (3, 'b', (5, 'c'; Explanation: Although this command works, it is a dangerous practice to explicitly insert values which are defined as auto-incremented. If some values are going to be added later without explicitly inserting team_id, SQL will have no way of knowing how to increment it without violating the unique key constraint. INSERT INTO referee ( first_ name VALUES (' John '; Explanation: The column last_name cannot be NULL.

14 INSERT INTO team ( team_name VALUES ('x', ('y'; INSERT INTO game ( game_date, home_team_id, away_team_id, referee_ id VALUES ( NOW (, 0, 1, 1337 ; DELETE FROM team WHERE team_id = 0 Explanation: Currently, a game can have a referee whose id is not in the database. Also, a team can be deleted even if there are games related to it in the database. To prevent using id of a non-existent referee and deleting related entries, you can use a foreign key. You will learn about the foreign keys later in this course. INSERT INTO team ( team_ name VALUES (' Real Madrid C. F.'; UPDATE team SET city_ name =' Barcelona ' WHERE team_ name = ' FC Barcelona '; INSERT INTO referee ( first_name, last_ name VALUES (' Jane ', ' Smith '; INSERT INTO referee ( first_name, last_ name VALUES (' Jane ', ' Smith '; Explanation: There is no constraint for unique (first_name, last_name tuple in the database. INSERT INTO game ( game_date, home_team_id, away_team_id, referee_ id VALUES (' ', 123, 321, 0, (' ', 123, 321, 1; Explanation: (game_date, home_team_id, away_team_id is a primary key in the game relation. For this reason, inserting these three values twice violates unique key constraint.

Assignment 6: SQL III

Assignment 6: SQL III Data Modelling and Databases Exercise dates: April 12/April 13, 2018 Ce Zhang, Gustavo Alonso Last update: April 16, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 6: SQL III This assignment

More information

Data Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018.

Data Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018. Data Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 4: SQL This assignment will

More information

Assignment 5: SQL II Solution

Assignment 5: SQL II Solution Data Modelling and Databases Exercise dates: March 29/March 30, 2018 Ce Zhang, Gustavo Alonso Last update: April 12, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 5: SQL II Solution This assignment

More information

ETH Zurich Spring Semester Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: March 27/March 31, Exercise 5: SQL II.

ETH Zurich Spring Semester Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: March 27/March 31, Exercise 5: SQL II. Data Modelling and Databases (DMDB) ETH Zurich Spring Semester 2017 Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: March Assistant(s): Claude Barthels, Eleftherios Sidirourgos, Last update:

More information

Assignment 2: Relational Model

Assignment 2: Relational Model Data Modelling and Databases Exercise dates: March 8/March 9, 208 Ce Zhang, Gustavo Alonso Last update: March 6, 208 Spring Semester 208 Head TA: Ingo Müller Assignment 2: Relational Model This assignment

More information

Data Modelling and Databases Exercise dates: March 20/March 27, 2017 Ce Zhang, Gustavo Alonso Last update: February 17, 2018.

Data Modelling and Databases Exercise dates: March 20/March 27, 2017 Ce Zhang, Gustavo Alonso Last update: February 17, 2018. Data Modelling and Databases Exercise dates: March 20/March 27, 2017 Ce Zhang, Gustavo Alonso Last update: February 17, 2018 Spring Semester 2018 Head TA: Ingo Müller Datasets set-up This assignment will

More information

Assignment 7: Integrity Constraints

Assignment 7: Integrity Constraints Data Modelling and Databases Exercise dates: April 19, 2018 Ce Zhang, Gustavo Alonso Last update: April 19, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 7: Integrity Constraints This assignment

More information

Assignment 2: Relational Model Solution

Assignment 2: Relational Model Solution Data Modelling and Databases Exercise dates: March 8/March 9, 208 Ce Zhang, Gustavo Alonso Last update: March 6, 208 Spring Semester 208 Head TA: Ingo Müller Assignment 2: Relational Model Solution This

More information

ETH Zurich Spring Semester Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: March 20/March 27, 2017.

ETH Zurich Spring Semester Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: March 20/March 27, 2017. Data Modelling and Databases (DMDB) ETH Zurich Spring Semester 2017 Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: March Assistant(s): Claude Barthels, Eleftherios Sidirourgos, Last update:

More information

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 10: INTRODUCTION TO SQL FULL RELATIONAL OPERATIONS MODIFICATION LANGUAGE Union, Intersection, Differences (select

More information

SQL. Char (30) can store ram, ramji007 or 80- b

SQL. Char (30) can store ram, ramji007 or 80- b SQL In Relational database Model all the information is stored on Tables, these tables are divided into rows and columns. A collection on related tables are called DATABASE. A named table in a database

More information

Assignment 3: Relational Algebra Solution

Assignment 3: Relational Algebra Solution Data Modelling and Databases Exercise dates: March 15/March 16, 2018 Ce Zhang, Gustavo Alonso Last update: April 13, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 3: Relational Algebra Solution

More information

1Z0-007 ineroduction to oracle9l:sql

1Z0-007 ineroduction to oracle9l:sql ineroduction to oracle9l:sql Q&A DEMO Version Copyright (c) 2007 Chinatag LLC. All rights reserved. Important Note Please Read Carefully For demonstration purpose only, this free version Chinatag study

More information

Assignment 12: Commit Protocols and Replication

Assignment 12: Commit Protocols and Replication Data Modelling and Databases Exercise dates: May 24 / May 25, 2018 Ce Zhang, Gustavo Alonso Last update: June 04, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 12: Commit Protocols and Replication

More information

CHAPTER: 4 ADVANCE SQL: SQL PERFORMANCE TUNING (12 Marks)

CHAPTER: 4 ADVANCE SQL: SQL PERFORMANCE TUNING (12 Marks) (12 Marks) 4.1 VIEW View: Views are virtual relations mainly used for security purpose, and can be provided on request by a particular user. A view can contain all rows of a table or select rows from a

More information

CS 582 Database Management Systems II

CS 582 Database Management Systems II Review of SQL Basics SQL overview Several parts Data-definition language (DDL): insert, delete, modify schemas Data-manipulation language (DML): insert, delete, modify tuples Integrity View definition

More information

SQL (Structured Query Language)

SQL (Structured Query Language) Lecture Note #4 COSC4820/5820 Database Systems Department of Computer Science University of Wyoming Byunggu Yu, 02/13/2001 SQL (Structured Query Language) 1. Schema Creation/Modification: DDL (Data Definition

More information

Exam. Question: Total Points: Score:

Exam. Question: Total Points: Score: FS 2016 Data Modelling and Databases Date: June 9, 2016 ETH Zurich Systems Group Prof. Gustavo Alonso Exam Name: Question: 1 2 3 4 5 6 7 8 9 10 11 Total Points: 15 20 15 10 10 15 10 15 10 10 20 150 Score:

More information

Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2016 CS 348 (Intro to DB Mgmt) SQL

More information

COUNT Function. The COUNT function returns the number of rows in a query.

COUNT Function. The COUNT function returns the number of rows in a query. Created by Ahsan Arif COUNT Function The COUNT function returns the number of rows in a query. The syntax for the COUNT function is: SELECT COUNT(expression) FROM tables WHERE predicates; Note: The COUNT

More information

SQL Data Query Language

SQL Data Query Language SQL Data Query Language André Restivo 1 / 68 Index Introduction Selecting Data Choosing Columns Filtering Rows Set Operators Joining Tables Aggregating Data Sorting Rows Limiting Data Text Operators Nested

More information

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables INDEX Exercise No Title 1 Basic SQL Statements 2 Restricting and Sorting Data 3 Single Row Functions 4 Displaying data from multiple tables 5 Creating and Managing Tables 6 Including Constraints 7 Manipulating

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2017 CS 348 (Intro to DB Mgmt) SQL

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Alexandra Roatiş David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2016 CS 348 SQL Winter

More information

Database Management Systems Paper Solution

Database Management Systems Paper Solution Database Management Systems Paper Solution Following questions have been asked in GATE CS exam. 1. Given the relations employee (name, salary, deptno) and department (deptno, deptname, address) Which of

More information

Database Management Systems,

Database Management Systems, Database Management Systems SQL Query Language (3) 1 Topics Aggregate Functions in Queries count sum max min avg Group by queries Set Operations in SQL Queries Views 2 Aggregate Functions Tables are collections

More information

Oracle 1Z MySQL 5.6 Developer.

Oracle 1Z MySQL 5.6 Developer. Oracle 1Z0-882 MySQL 5.6 Developer http://killexams.com/exam-detail/1z0-882 SELECT... WHERE DATEDIFF (dateline, 2013-01-01 ) = 0 C. Use numeric equivalents for comparing the two dates: SELECT...WHERE MOD(UNIX_TIMESTAMP

More information

CMP-3440 Database Systems

CMP-3440 Database Systems CMP-3440 Database Systems Advanced SQL Lecture 07 zain 1 Select Statement - Aggregates ISO standard defines five aggregate functions: COUNT returns number of values in specified column. SUM returns sum

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

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

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies Databases - 4 Other relational operations and DDL How to write RA expressions for dummies Step 1: Identify the relations required and CP them together Step 2: Add required selections to make the CP Step

More information

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of The SQL Query Language Data Definition Basic Query

More information

Tables From Existing Tables

Tables From Existing Tables Creating Tables From Existing Tables After completing this module, you will be able to: Create a clone of an existing table. Create a new table from many tables using a SQL SELECT. Define your own table

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2012 CS 348 (Intro to DB

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2012 CS 348 (Intro to DB

More information

WHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints

WHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints SQL KEREM GURBEY WHAT IS SQL Database query language, which can also: Define structure of data Modify data Specify security constraints DATA DEFINITION Data-definition language (DDL) provides commands

More information

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey INTERMEDIATE SQL GOING BEYOND THE SELECT Created by Brian Duffey WHO I AM Brian Duffey 3 years consultant at michaels, ross, and cole 9+ years SQL user What have I used SQL for? ROADMAP Introduction 1.

More information

SQL Data Manipulation Language. Lecture 5. Introduction to SQL language. Last updated: December 10, 2014

SQL Data Manipulation Language. Lecture 5. Introduction to SQL language. Last updated: December 10, 2014 Lecture 5 Last updated: December 10, 2014 Throrought this lecture we will use the following database diagram Inserting rows I The INSERT INTO statement enables inserting new rows into a table. The basic

More information

Lecture 04: SQL. Monday, April 2, 2007

Lecture 04: SQL. Monday, April 2, 2007 Lecture 04: SQL Monday, April 2, 2007 1 Outline The Project Nulls (6.1.6) Outer joins (6.3.8) Database Modifications (6.5) 2 NULLS in SQL Whenever we don t have a value, we can put a NULL Can mean many

More information

Database Systems CSE 303. Outline. Lecture 06: SQL. What is Sub-query? Sub-query in WHERE clause Subquery

Database Systems CSE 303. Outline. Lecture 06: SQL. What is Sub-query? Sub-query in WHERE clause Subquery Database Systems CSE 303 Lecture 06: SQL 2016 Subquery Outline What is a Subquery Subquery in WHERE clause >ALL, >ANY, >=ALL,

More information

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select,

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select, Sub queries A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select, Result of the inner query is passed to the main

More information

Intermediate SQL ( )

Intermediate SQL ( ) CSL 451 Introduction to Database Systems Intermediate SQL (4.1-4.4) Department of Computer Science and Engineering Indian Institute of Technology Ropar Narayanan (CK) Chatapuram Krishnan! Summary Join

More information

Principles of Data Management

Principles of Data Management Principles of Data Management Alvin Lin August 2018 - December 2018 Structured Query Language Structured Query Language (SQL) was created at IBM in the 80s: SQL-86 (first standard) SQL-89 SQL-92 (what

More information

Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query

More information

Assignment Grading Rubric

Assignment Grading Rubric Final Project Outcomes addressed in this activity: Overview and Directions: 1. Create a new Empty Database called Final 2. CREATE TABLES The create table statements should work without errors, have the

More information

Data Modelling and Databases. Exercise Session 2: Relational Model

Data Modelling and Databases. Exercise Session 2: Relational Model Data Modelling and Databases Exercise Session 2: Relational Model 1 Interactive Session Format You can watch others swim as often as you want. In the end, you can only learn it by doing it yourself. Alfons

More information

Lecture 04: SQL. Wednesday, October 4, 2006

Lecture 04: SQL. Wednesday, October 4, 2006 Lecture 04: SQL Wednesday, October 4, 2006 1 Outline The Project Nulls (6.1.6) Outer joins (6.3.8) Database Modifications (6.5) 2 The Project Application: Boutique online music and book store Project:

More information

The SQL data-definition language (DDL) allows defining :

The SQL data-definition language (DDL) allows defining : Introduction to SQL Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query Structure Additional Basic Operations Set Operations Null Values Aggregate Functions Nested Subqueries

More information

1 SQL Structured Query Language

1 SQL Structured Query Language 1 SQL Structured Query Language 1.1 Tables In relational database systems (DBS) data are represented using tables (relations). A query issued against the DBS also results in a table. A table has the following

More information

T-SQL Training: T-SQL for SQL Server for Developers

T-SQL Training: T-SQL for SQL Server for Developers Duration: 3 days T-SQL Training Overview T-SQL for SQL Server for Developers training teaches developers all the Transact-SQL skills they need to develop queries and views, and manipulate data in a SQL

More information

EE221 Databases Practicals Manual

EE221 Databases Practicals Manual EE221 Databases Practicals Manual Lab 1 An Introduction to SQL Lab 2 Database Creation and Querying using SQL Assignment Data Analysis, Database Design, Implementation and Relation Normalisation School

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 6 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement GIFT Department of Computing Science [Spring 2013] CS-217: Database Systems Lab-2 Manual Data Selection and Filtering using the SELECT Statement V1.0 4/12/2016 Introduction to Lab-2 This lab reinforces

More information

Midterm Review. Winter Lecture 13

Midterm Review. Winter Lecture 13 Midterm Review Winter 2006-2007 Lecture 13 Midterm Overview 3 hours, single sitting Topics: Relational model relations, keys, relational algebra expressions SQL DDL commands CREATE TABLE, CREATE VIEW Specifying

More information

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL In This Lecture Yet More SQL Database Systems Lecture 9 Natasha Alechina Yet more SQL ORDER BY Aggregate functions and HAVING etc. For more information Connoly and Begg Chapter 5 Ullman and Widom Chapter

More information

Slides by: Ms. Shree Jaswal

Slides by: Ms. Shree Jaswal Slides by: Ms. Shree Jaswal Overview of SQL, Data Definition Commands, Set operations, aggregate function, null values, Data Manipulation commands, Data Control commands, Views in SQL, Complex Retrieval

More information

Assignment 1: Entity-Relationship Model Solution

Assignment 1: Entity-Relationship Model Solution Data odelling and Databases Exercise dates: arch /arch 2, 208 Ce Zhang, Gustavo Alonso Last update: arch 08, 208 Spring Semester 208 Head TA: Ingo üller Assignment : Entity-Relationship odel Solution This

More information

ASSIGNMENT NO Computer System with Open Source Operating System. 2. Mysql

ASSIGNMENT NO Computer System with Open Source Operating System. 2. Mysql ASSIGNMENT NO. 3 Title: Design at least 10 SQL queries for suitable database application using SQL DML statements: Insert, Select, Update, Delete with operators, functions, and set operator. Requirements:

More information

Structure Query Language (SQL)

Structure Query Language (SQL) Structure Query Language (SQL) 1 6.12.2 OR operator OR operator is also used to combine multiple conditions with Where clause. The only difference between AND and OR is their behavior. When we use AND

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

SQL Structured Query Language Introduction

SQL Structured Query Language Introduction SQL Structured Query Language Introduction Rifat Shahriyar Dept of CSE, BUET Tables In relational database systems data are represented using tables (relations). A query issued against the database also

More information

Introduction to Oracle9i: SQL

Introduction to Oracle9i: SQL Oracle 1z0-007 Introduction to Oracle9i: SQL Version: 22.0 QUESTION NO: 1 Oracle 1z0-007 Exam Examine the data in the EMPLOYEES and DEPARTMENTS tables. You want to retrieve all employees, whether or not

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

1 SQL Structured Query Language

1 SQL Structured Query Language 1 SQL Structured Query Language 1.1 Tables In relational database systems (DBS) data are represented using tables (relations). A query issued against the DBS also results in a table. A table has the following

More information

Subquery: There are basically three types of subqueries are:

Subquery: There are basically three types of subqueries are: Subquery: It is also known as Nested query. Sub queries are queries nested inside other queries, marked off with parentheses, and sometimes referred to as "inner" queries within "outer" queries. Subquery

More information

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Relational Databases Fall 2017 Lecture 7

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Relational Databases Fall 2017 Lecture 7 SQL DATA DEFINITION: KEY CONSTRAINTS CS121: Relational Databases Fall 2017 Lecture 7 Data Definition 2 Covered most of SQL data manipulation operations Continue exploration of SQL data definition features

More information

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] 1. What is DBMS? A Database Management System (DBMS) is a program that controls creation, maintenance and use

More information

MTA Database Administrator Fundamentals Course

MTA Database Administrator Fundamentals Course MTA Database Administrator Fundamentals Course Session 1 Section A: Database Tables Tables Representing Data with Tables SQL Server Management Studio Section B: Database Relationships Flat File Databases

More information

Lecture 3 SQL. Shuigeng Zhou. September 23, 2008 School of Computer Science Fudan University

Lecture 3 SQL. Shuigeng Zhou. September 23, 2008 School of Computer Science Fudan University Lecture 3 SQL Shuigeng Zhou September 23, 2008 School of Computer Science Fudan University Outline Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries Derived Relations Views

More information

QQ Group

QQ Group QQ Group: 617230453 1 Extended Relational-Algebra-Operations Generalized Projection Aggregate Functions Outer Join 2 Generalized Projection Extends the projection operation by allowing arithmetic functions

More information

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO INSERT INTO DEPT VALUES(4, 'Prog','MO'); The result

More information

Data Modelling and Databases. Exercise Session 7: Integrity Constraints

Data Modelling and Databases. Exercise Session 7: Integrity Constraints Data Modelling and Databases Exercise Session 7: Integrity Constraints 1 Database Design Textual Description Complete Design ER Diagram Relational Schema Conceptual Modeling Logical Modeling Physical Modeling

More information

IBM DB2 9 Family Fundamentals. Download Full Version :

IBM DB2 9 Family Fundamentals. Download Full Version : IBM 000-730 DB2 9 Family Fundamentals Download Full Version : http://killexams.com/pass4sure/exam-detail/000-730 Answer: D QUESTION: 292 The EMPLOYEE table contains the following information: EMPNO NAME

More information

Computing for Medicine (C4M) Seminar 3: Databases. Michelle Craig Associate Professor, Teaching Stream

Computing for Medicine (C4M) Seminar 3: Databases. Michelle Craig Associate Professor, Teaching Stream Computing for Medicine (C4M) Seminar 3: Databases Michelle Craig Associate Professor, Teaching Stream mcraig@cs.toronto.edu Relational Model The relational model is based on the concept of a relation or

More information

LIKE Condition. % allows you to match any string of any length (including zero length)

LIKE Condition. % allows you to match any string of any length (including zero length) Created by Ahsan Arif LIKE Condition The LIKE condition allows you to use wildcards in the where clause of an SQL statement. This allows you to perform pattern matching. The LIKE condition can be used

More information

CMP-3440 Database Systems

CMP-3440 Database Systems CMP-3440 Database Systems Relational DB Languages Relational Algebra, Calculus, SQL Lecture 05 zain 1 Introduction Relational algebra & relational calculus are formal languages associated with the relational

More information

Exam Actual. Higher Quality. Better Service! QUESTION & ANSWER

Exam Actual. Higher Quality. Better Service! QUESTION & ANSWER Higher Quality Better Service! Exam Actual QUESTION & ANSWER Accurate study guides, High passing rate! Exam Actual provides update free of charge in one year! http://www.examactual.com Exam : 1Z0-047 Title

More information

Data Manipulation Language (DML)

Data Manipulation Language (DML) In the name of Allah Islamic University of Gaza Faculty of Engineering Computer Engineering Department ECOM 4113 DataBase Lab Lab # 3 Data Manipulation Language (DML) El-masry 2013 Objective To be familiar

More information

Rani Durgavati Vishwavidyalaya Jabalpur (M.P.) (UICSA) Master of Computer Application (MCA) Practical List of. MCA III SEM Session -2010

Rani Durgavati Vishwavidyalaya Jabalpur (M.P.) (UICSA) Master of Computer Application (MCA) Practical List of. MCA III SEM Session -2010 Rani Durgavati Vishwavidyalaya Jabalpur (M.P.) (UICSA) Master of Computer Application (MCA) Practical List of MCA III SEM Session -2010 MCA-301 - Object Oriented Programming in C++ 1. WAP to generate Fibonacci

More information

Database Management Systems,

Database Management Systems, Database Management Systems SQL Query Language (1) 1 Topics Introduction SQL History Domain Definition Elementary Domains User-defined Domains Creating Tables Constraint Definition INSERT Query SELECT

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

Assignment 12: Commit Protocols and Replication Solution

Assignment 12: Commit Protocols and Replication Solution Data Modelling and Databases Exercise dates: May 24 / May 25, 2018 Ce Zhang, Gustavo Alonso Last update: June 04, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 12: Commit Protocols and Replication

More information

1) Introduction to SQL

1) Introduction to SQL 1) Introduction to SQL a) Database language enables users to: i) Create the database and relation structure; ii) Perform insertion, modification and deletion of data from the relationship; and iii) Perform

More information

Sample Question Paper

Sample Question Paper Sample Question Paper Marks : 70 Time:3 Hour Q.1) Attempt any FIVE of the following. a) List any four applications of DBMS. b) State the four database users. c) Define normalization. Enlist its type. d)

More information

Exam code: Exam name: Database Fundamentals. Version 16.0

Exam code: Exam name: Database Fundamentals. Version 16.0 98-364 Number: 98-364 Passing Score: 800 Time Limit: 120 min File Version: 16.0 Exam code: 98-364 Exam name: Database Fundamentals Version 16.0 98-364 QUESTION 1 You have a table that contains the following

More information

Insertions, Deletions, and Updates

Insertions, Deletions, and Updates Insertions, Deletions, and Updates Lecture 5 Robb T. Koether Hampden-Sydney College Wed, Jan 24, 2018 Robb T. Koether (Hampden-Sydney College) Insertions, Deletions, and Updates Wed, Jan 24, 2018 1 / 17

More information

Oracle Exam 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Version: 7.0 [ Total Questions: 100 ]

Oracle Exam 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Version: 7.0 [ Total Questions: 100 ] s@lm@n Oracle Exam 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Version: 7.0 [ Total Questions: 100 ] Oracle 1z0-882 : Practice Test Question No : 1 Consider the statements: Mysql> drop function

More information

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions.

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions. COSC 304 Introduction to Database Systems Relational Model and Algebra Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was

More information

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1 SQL Fundamentals Chapter 3 Class 03: SQL Fundamentals 1 Class 03: SQL Fundamentals 2 SQL SQL (Structured Query Language): A language that is used in relational databases to build and query tables. Earlier

More information

Mahathma Gandhi University

Mahathma Gandhi University Mahathma Gandhi University BSc Computer science III Semester BCS 303 OBJECTIVE TYPE QUESTIONS Choose the correct or best alternative in the following: Q.1 In the relational modes, cardinality is termed

More information

Private Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH

Private Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH Private Institute of Aga 2018 NETWORK DATABASE LECTURER NIYAZ M. SALIH Data Definition Language (DDL): String data Types: Data Types CHAR(size) NCHAR(size) VARCHAR2(size) Description A fixed-length character

More information

Database Programming with SQL

Database Programming with SQL Database Programming with SQL 2-1 Objectives This lesson covers the following objectives: Apply the concatenation operator to link columns to other columns, arithmetic expressions, or constant values to

More information

Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course:

Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course: Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course: 20762C Developing SQL 2016 Databases Module 1: An Introduction to Database Development Introduction to the

More information

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 9: INTRODUCTION TO SQL SELECT-FROM-WHERE STATEMENTS SUBQUERIES Set-up the database 1. Log in to your machine using

More information

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until Databases Relational Model, Algebra and operations How do we model and manipulate complex data structures inside a computer system? Until 1970.. Many different views or ways of doing this Could use tree

More information

Study Guide for: Oracle Database SQL Certified Expert Exam Guide (Exam 1Z0-047)

Study Guide for: Oracle Database SQL Certified Expert Exam Guide (Exam 1Z0-047) Study Guide for: Oracle Database SQL Certified Expert Exam Guide (Exam 1Z0-047) Study Material for: Student 08.10.2010 15:49:30 Examine the following data listing for table WORKERS: WORKER_ID LAST_NAME

More information

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity COSC 416 NoSQL Databases Relational Model (Review) Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was proposed by E. F. Codd

More information

Chapter 8 SQL-99: Schema Definition, Basic Constraints, and Queries

Chapter 8 SQL-99: Schema Definition, Basic Constraints, and Queries Copyright 2004 Pearson Education, Inc. Chapter 8 SQL-99: Schema Definition, Basic Constraints, and Queries Copyright 2004 Pearson Education, Inc. 1 Data Definition, Constraints, and Schema Changes Used

More information

Database implementation Further SQL

Database implementation Further SQL IRU SEMESTER 2 January 2010 Semester 1 Session 2 Database implementation Further SQL Objectives To be able to use more advanced SQL statements, including Renaming columns Order by clause Aggregate functions

More information