Databases 2011 The Relational Model and SQL

Size: px
Start display at page:

Download "Databases 2011 The Relational Model and SQL"

Transcription

1 Databases 2011 Christian S. Jensen Computer Science, Aarhus University

2 What is a Database? Main Entry: da ta base Pronunciation: \ˈdā-tə-ˌbās, ˈda- also ˈdä-\ Function: noun Date: circa 1962 : a usually large collection of data organized especially for rapid search and retrieval (as by a computer) database transitive verb Queries are much more general than searching Database Management System (DBMS): Efficient, convenient, and safe storage of and multi-user access to very large amounts of persistent data 2

3 What is a Database? Main Entry: da ta base Pronunciation: \ˈdā-tə-ˌbās, ˈda- also ˈdä-\ Function: noun Date: circa 1962 : a usually large collection of data organized especially for rapid search and retrieval (as by a computer) database transitive verb Bank accounts Queries are much more general than searching Blog archives Database Management System (DBMS): Google.com Efficient, convenient, and safe storage of and Amazon.com multi-user access to massive amounts of persistent data Human genome Student records 3

4 Data Model A (mathematical) representation of data tables/relations sets, multisets, lists trees, graphs Operations on data insert, delete, update, query Constraints on data data types uniqueness dependencies 4

5 The Relational Data Model Data is stored in tables (relations) name age city Joe 22 London Jacques 27 Paris Jose 34 Madrid Simple but flexible and support many real-world applications 5

6 The Relational Data Model Data is stored in tables (relations) row (tuple) name age city Joe 22 London Jacques 27 Paris Jose 34 Madrid 6

7 The Relational Data Model Data is stored in tables (relations) schema name age city Joe 22 London Jacques 27 Paris Jose 34 Madrid 7

8 The Relational Data Model Data is stored in tables (relations) name age city Joe 22 London Jacques 27 Paris Jose 34 Madrid column 8

9 The Relational Data Model Data is stored in tables (relations) name age city Joe 22 London Jacques 27 Paris Jose 34 Madrid attribute 9

10 The Relational Data Model Data is stored in tables (relations) name age city Joe 22 London Jacques 27 Paris Jose 34 Madrid attribute value 10

11 The Relational Data Model Data is stored in tables (relations) Abstract tables name age city Joe 22 London Jacques 27 Paris Jose 34 Madrid invariant under permutation of rows and columns no information is stored in the order May or may not allow duplicate rows 11

12 The Relational Data Model Data is stored in tables (relations) Abstract tables city name age Madrid Jose 34 London Joe 22 Paris Jacques 27 invariant under permutation of rows and columns no information is stored in the order May or may not allow duplicate rows 12

13 NULL Values An attribute value may be NULL it is unknown no value exists it is unknown or does not exist animal color zoo lion yellow Copenhagen crocodile green London Tyrannosaurus Rex NULL NULL polar bear white Berlin NULL values are treated specially 13

14 Advantages of The Relational Model A simple, intuitive model Often convenient for real-life data but richer models, e.g., XML, are useful in some settings An elegant mathematical foundation set and multi-set theory relational algebra and calculi Allows efficient algorithms Industrial strength implementations are available 14

15 Schemas Relation schema name of the relation names of the attributes types of the attributes constraints Database schema collection of all relation schemas 15

16 Running Example The database behind a tiny calendar system Rooms People Meetings Participants Equipment 16

17 Rooms room capacity Turing Ada Store-Aud 286 room: the name of a room capacity: the number of people that it will hold 17

18 People userid name group office csj Christian S. Jensen vip Turing-216 doina Doina Bucur phd NULL bnielsen Kai Birger Nielsen tap Hopper-017 userid: unique user name name: ordinary name group: vip, tap, phd office: a room or NULL 18

19 Meetings meetid date slot owner what csj ddb csj ddb ceikute TA meeting meetid: a unique id date: the date of the meeting slot: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 owner: the userid of the owner what: a textual description 19

20 Participants meetid pid status Store-Aud a csj a radaelli d meetid: the id of the meeting pid: a userid or a room status: u(nknown), a(ccept), d(ecline) 20

21 Equipment room Store-Aud Store-Aud Hopper-017 type projector whiteboard mini-fridge room: the name of a room type: the type of equipment 21

22 SQL Structured Query Language Invented by IBM in the 1970s (many versions) High-Level, declarative, no low-level manipulations Algebraic foundations Representations, operations, constraints Query optimization MySQL, DB2, Oracle, SQL Server, 22

23 Declaring Tables (1/3) CREATE TABLE Rooms ( room VARCHAR(15), capacity INT ); CREATE TABLE People ( name VARCHAR(40), office VARCHAR(15), userid VARCHAR(15), `group` CHAR(3) ); 23

24 Declaring Tables (2/3) CREATE TABLE Meetings ( meetid INT, date DATE, slot INT, owner VARCHAR(15), what VARCHAR(40) ); 24

25 Declaring Tables (3/3) CREATE TABLE Participants ( meetid INT, pid VARCHAR(15), status CHAR(1) ); CREATE TABLE Equipment ( room VARCHAR(15), type VARCHAR(20) ); 25

26 SQL Data Types INT 217 CHAR(2) 'aa', 'ab', '12', '++' VARCHAR(5) '', '12345', 'foo', 'x''y' FLOAT 3.14, 42, DATE ' ' TIME '14:15:00' TEXT a text file BLOB a movie 26

27 Refinements NOT NULL the value cannot be NULL DEFAULT value a default value is specified UNIQUE the value is unique in the table unless it is NULL PRIMARY KEY the value is unique in the table the value is never NULL special syntax for multi-attribute primary keys 27

28 Refined Tables (1/3) CREATE TABLE Rooms ( room VARCHAR(15) PRIMARY KEY, capacity INT NOT NULL ); CREATE TABLE People ( name VARCHAR(40) NOT NULL, office VARCHAR(15), userid VARCHAR(15) PRIMARY KEY, `group` CHAR(3) ); 28

29 Declaring Tables (2/3) CREATE TABLE Meetings ( meetid INT PRIMARY KEY, date DATE, slot INT, owner VARCHAR(15) NOT NULL, what VARCHAR(40) ); 29

30 Declaring Tables (3/3) CREATE TABLE Participants ( meetid INT NOT NULL, pid VARCHAR(15) NOT NULL, status CHAR(1) DEFAULT 'u' ); CREATE TABLE Equipment ( room VARCHAR(15) NOT NULL, type VARCHAR(20) NOT NULL, PRIMARY KEY (room, type) ); 30

31 SELECT-FROM-WHERE The basic form of an SQL query SELECT desired attributes FROM one or more tables WHERE condition about the involved rows 31

32 Simple Example Which meetings ( what ) have csj arranged? meetid what date slot owner what ddb csj ddb ddb csj ddb ceikute TA meeting SELECT what FROM Meetings WHERE owner = 'csj'; 32

33 Loop Semantics for Single Table Loop through all rows in the table Check if the condition is true Project the rows onto the desired attributes Note that duplicates are kept... 33

34 Renaming in SELECT The selected attributes can be given new names SELECT name,`group` AS category FROM People WHERE office = 'Ada-230'; name Vaida Ceikute Rasmus Ibsen-Jensen category phd phd 34

35 Expressions in SELECT The attributes may have computed values SELECT owner, date, slot*60 AS minute FROM Meetings WHERE owner = 'csj'; owner date minute csj csj

36 Conditions in WHERE AND, OR, NOT, =, <>, <, >, <=, >=, LIKE,... SELECT owner, what FROM Meetings WHERE slot >= 12 AND slot < 16 AND what LIKE '%beer%'; owner anderssk anderssk anderssk what Afternoon beer Belgian beer testing Return empty beer bottles 36

37 3-Valued Logic Arithmetic operations on NULL yield NULL Any comparison with NULL yields unknown This gives 3 truth values: true, false, unknown Boolean connectives are defined appropriately AND tt ff u OR tt ff u NOT tt tt ff u tt tt tt tt tt ff ff ff ff ff ff tt ff u ff tt u u ff u u tt u u u u The WHERE clause accepts if the result is true 37

38 A Surprise? People userid name group office csj Christian S. Jensen vip Turing-216 doina Doina Bucur phd NULL bnielsen Kai Birger Nielsen tap Hopper-017 SELECT userid FROM People WHERE office='turing-216' OR office<>'turing-216'; userid csj bnielsen 38

39 Testing for NULL People userid name group office csj Christian S. Jensen vip Turing-216 doina Doina Bucur phd NULL bnielsen Kai Birger Nielsen tap Hopper-017 SELECT userid FROM People WHERE office IS NULL; userid doina 39

40 Multiple Relations Who have booked meetings on August 23, 2010? SELECT name FROM People, Meetings WHERE date = ' ' AND owner = userid; The relations are joined 40

41 Multiple Relations Example userid name group office csj Christian S. Jensen vip Turing-216 doina Doina Bucur phd NULL bnielsen Kai Birger Nielsen tap Hopper-017 meetid date slot owner what csj ddb csj ddb ceikute TA meeting 41

42 General Loop Semantics Loop through all rows in all tables For each combination check if the condition is true project the rows onto the desired attributes Note that duplicates are still kept... 42

43 Prefixing Attribute Variables Avoid possible name clashes SELECT People.name FROM People, Meetings WHERE Meetings.date = ' ' AND Meetings.owner = People.userid; 43

44 Multiple Relations Who shares a room? userid name group office csj Christian S. Jensen vip Turing-216 vaida Vaida Ceikute phd Turing-216 ira Ira Assent vip Turing-217 roomie1 Christian S. Jensen roomie2 Vaida Ceikute 44

45 Naming Row Variables Enables self-joins SELECT p1.name AS roomie1, p2.name AS roomie2 FROM People p1, People p2 WHERE p1.office = p2.office AND p1.userid <> p2.userid; A table of all roommates... 45

46 Avoiding Symmetric Pairs SELECT p1.name AS roomie1, p2.name AS roomie2 FROM People p1, People p2 WHERE p1.office = p2.office AND p1.userid < p2.userid; 46

47 Aggregation The SELECT clause may involve aggregate functions SUM AVG COUNT MIN MAX NULLs are ignored in these computations Except that count(*) counts all rows 47

48 Requirements Aggregation of a column computes a 1 a 2 a 3... a n for some operator x a 1 a 2 This is only well-formed if is commutative: a b = b a associative: (a b) c = a (b c) since the rows may be permuted a 3... a n 48

49 Simple Example What is the average capacity of a room? SELECT AVG(capacity) AS average FROM Rooms; average

50 Avoiding Duplicates SELECT DISTINCT removes duplicates This is expensive! But sometime necessary... What kinds of equipment do we have? SELECT DISTINCT type FROM Equipment; 50

51 Avoiding Duplicates in Aggregation How many kinds of equipment do we have? SELECT COUNT(DISTINCT type) as number FROM Equipment; number 4 51

52 Scalar Functions Lots of useful functions are available integer and float functions string functions calendar functions... SELECT CHARACTER_LENGTH(name), FROM People; UPPER(`group`) 52

53 Subqueries Any query in parentheses can be used in FROM clauses WHERE clauses A query may be used as a value if it returns only one row and one column otherwise, a run-time error occurs 53

54 Simple Example Who shares an office with Ira? SELECT name FROM People WHERE office = (SELECT office FROM People WHERE userid='ira'); 54

55 Membership Tests IN and NOT IN test membership in tables Who has csj arranged to meet? SELECT pid FROM Participants WHERE meetid IN (SELECT meetid FROM Meetings WHERE owner='csj') AND pid NOT IN (SELECT room FROM Rooms); 55

56 Membership Tests meetid pid status Store-Aud a csj a sigurd d meetid date slot owner what csj ddb csj ddb ceikute TA meeting 56

57 Correlated Subqueries Which meetings exceed the capacity of a room? SELECT meetid FROM Meetings WHERE (SELECT COUNT(DISTINCT pid) FROM Participants WHERE meetid=meetings.meetid AND status<>'d' AND pid NOT IN (SELECT room FROM Rooms) ) > (SELECT capacity FROM Rooms, Participants WHERE room=pid AND meetid=meetings.meetid) ; 57

58 Correlated Subqueries Which meetings exceed the capacity of a room? SELECT meetid FROM Meetings static nested scope rules WHERE (SELECT COUNT(DISTINCT pid) FROM Participants WHERE meetid=meetings.meetid AND status<>'d' AND pid NOT IN (SELECT room FROM Rooms) ) > (SELECT capacity FROM Rooms, Participants WHERE room=pid AND meetid=meetings.meetid) ; 58

59 EXISTS and NOT EXISTS Check for emptiness or non-emptiness of a table Who is alone in an office? SELECT name FROM People p1 WHERE NOT EXISTS ( SELECT * FROM People WHERE office = p1.office AND userid <> p1.userid ); 59

60 ANY and ALL Allow comparisons against any row in a subquery all rows in a subquery Which are the latest meetings that are planned? SELECT what FROM Meetings WHERE date >= ALL( SELECT date FROM Meetings ); 60

61 UNION, INTERSECT, and EXCEPT Treat tables with the same schema as sets remove duplicates (unless ALL is added) computes,, and \ Who do not participate in a meeting they have themselves arranged? (SELECT owner AS userid, meetid FROM Meetings) EXCEPT (SELECT pid AS userid, meetid FROM Participants); 61

62 EXCEPT and MySQL Except is not supported in MySQL Use NOT EXISTS instead. SELECT owner AS userid, meetid FROM Meetings WHERE NOT EXISTS (SELECT pid AS userid, meetid FROM Participants); 62

63 The JOIN Operator T1 JOIN T2 ON condition is syntactic sugar for: SELECT * FROM T1,T2 WHERE condition 63

64 Dangling Rows and FULL JOIN T1 JOIN T2 ON condition A row in T1 or T2 that does not match a row in the other table is dangling An ordinary JOIN throws away dangling rows A OUTER JOIN preserves dangling rows by padding them with NULL values A LEFT or RIGHT JOIN preserves dangling rows from one argument only 64

65 Simple Example In which offices are meetings planned? All offices with meetings or NULL SELECT office, meetid FROM People LEFT JOIN Participants ON pid=office; Only those offices with meetings SELECT office, meetid FROM People JOIN Participants ON pid=office; 65

66 People and Participants userid name group office csj Christian S. Jensen vip Turing-216 doina Doina Bucur phd NULL bnielsen Kai Birger Nielsen tap Hopper-017 meetid pid status Store-Aud a csj a sigurd d 66

67 Grouping SELECT-FROM-WHERE-GROUP BY Rows are grouped by a set of attributes Aggregations in SELECT are done for each group The attributes in SELECT must be either aggregates or mentioned in the GROUP BY clause 67

68 Simple Example How many meetings have each person arranged? SELECT owner, COUNT(meetid) as number FROM Meetings GROUP BY owner; owner number amoeller 4 kjensen 1 csj 3 68

69 Advanced Example What is the average number of invitations for the meetings that each person has arranged? SELECT owner, AVG(pidno) AS average FROM (SELECT owner, m.meetid, COUNT(pid) as pidno FROM Meetings m, Participants p WHERE m.meetid = p.meetid GROUP BY owner, m.meetid) AS ownavg GROUP BY owner; 69

70 HAVING A HAVING clause may eliminate some groups Which offices have more than one occupant? SELECT office FROM People GROUP BY office HAVING COUNT(*) > 1; Attributes in HAVING must be aggregates or mentioned in GROUP BY 70

71 Modifications SQL commands may modify the database Three kinds of modifications insert one or more rows delete one or more rows update existing rows or columns Modifications do not return a result 71

72 Inserting a Single Row INSERT INTO table VALUES (list of values); INSERT INTO Participants VALUES (42432, 'mis', 'a'); Optionally specify attribute names: INSERT INTO Participants(pid, status, meetid) VALUES ('mis', 'a', 42432); Missing values are NULL or defaults 72

73 Inserting a Subquery Invite everyone Anders meets with to his Belgian beer tasting INSERT INTO Participants ( SELECT AS meetid, pid, 'u' AS status FROM Meetings, Participants WHERE Meetings.meetid=Participants.meetid AND owner = 'anderssk' AND pid <> 'anderssk' AND pid NOT IN (SELECT room FROM Rooms)); 73

74 Deleting Some Rows DELETE FROM table WHERE condition; Delete Christian's office DELETE FROM Rooms WHERE room='turing-216'; Delete all offices DELETE FROM Rooms; 74

75 Deleting a Subquery Delete all people with a roommate DELETE FROM People p WHERE EXISTS( SELECT * FROM People WHERE office = p.office AND userid <> p.userid ); 75

76 Meaning of Deletion First the condition is computed for all rows Then the deletions are performed Otherwise the last person in a multi-person office would not be deleted! 76

77 Update UPDATE table SET attribute assignments WHERE condition; Move Anders to a smaller office UPDATE People SET office = 'Turing-213' WHERE userid = 'anderssk'; 77

78 SQL is Everywhere 78

The Relational Model and SQL

The Relational Model and SQL Databases 2009 Michael I. Schwartzbach Computer Science, University of Aarhus 1 What is a Database? Main Entry: da ta base Pronunciation: \dā-tə-bās, da- also dä-\ Function: noun Date: circa 1962 : a usually

More information

Databases 2012 Constraints, Triggers, and Views

Databases 2012 Constraints, Triggers, and Views Databases 2012 Christian S. Jensen Computer Science, Aarhus University Constraints Enforced relationships among data single-attribute keys multi-attribute keys foreign keys attribute constraints row constraints

More information

Databases Normalization. Christian S. Jensen Computer Science, Aarhus University

Databases Normalization. Christian S. Jensen Computer Science, Aarhus University Databases 2010 Christian S. Jensen Computer Science, Aarhus University Acknowledgments: revised version of slides developed by Michael I. Schwartzbach Database Anomalies Redundancy anomaly information

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

Relational Model, Relational Algebra, and SQL

Relational Model, Relational Algebra, and SQL Relational Model, Relational Algebra, and SQL August 29, 2007 1 Relational Model Data model. constraints. Set of conceptual tools for describing of data, data semantics, data relationships, and data integrity

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

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

SQL: Data Manipulation Language. csc343, Introduction to Databases Diane Horton Winter 2017

SQL: Data Manipulation Language. csc343, Introduction to Databases Diane Horton Winter 2017 SQL: Data Manipulation Language csc343, Introduction to Databases Diane Horton Winter 2017 Introduction So far, we have defined database schemas and queries mathematically. SQL is a formal language for

More information

SQL: csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Sina Meraji. Winter 2018

SQL: csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Sina Meraji. Winter 2018 SQL: csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Sina Meraji Winter 2018 Introduction So far, we have defined database schemas and queries mathematically. SQL is a

More information

SQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez

SQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez SQL Queries for Mere Mortals Third Edition A Hands-On Guide to Data Manipulation in SQL John L. Viescas Michael J. Hernandez r A TT TAddison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco

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

SQL. Lecture 4 SQL. Basic Structure. The select Clause. The select Clause (Cont.) The select Clause (Cont.) Basic Structure.

SQL. Lecture 4 SQL. Basic Structure. The select Clause. The select Clause (Cont.) The select Clause (Cont.) Basic Structure. SL Lecture 4 SL Chapter 4 (Sections 4.1, 4.2, 4.3, 4.4, 4.5, 4., 4.8, 4.9, 4.11) Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries Derived Relations Modification of the Database

More information

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries Introduction to SQL Select-From-Where Statements Multirelation Queries Subqueries 122 Why SQL? SQL is a very-high-level language. Say what to do rather than how to do it. Database management system figures

More information

Database Systems SQL SL03

Database Systems SQL SL03 Inf4Oec10, SL03 1/52 M. Böhlen, ifi@uzh Informatik für Ökonomen II Fall 2010 Database Systems SQL SL03 Data Definition Language Table Expressions, Query Specifications, Query Expressions Subqueries, Duplicates,

More information

Relational Databases

Relational Databases Relational Databases Jan Chomicki University at Buffalo Jan Chomicki () Relational databases 1 / 49 Plan of the course 1 Relational databases 2 Relational database design 3 Conceptual database design 4

More information

Database Systems SQL SL03

Database Systems SQL SL03 Checking... Informatik für Ökonomen II Fall 2010 Data Definition Language Database Systems SQL SL03 Table Expressions, Query Specifications, Query Expressions Subqueries, Duplicates, Null Values Modification

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

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 2: Relations and SQL. September 5, Lecturer: Rasmus Pagh

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 2: Relations and SQL. September 5, Lecturer: Rasmus Pagh Introduction to Databases, Fall 2005 IT University of Copenhagen Lecture 2: Relations and SQL September 5, 2005 Lecturer: Rasmus Pagh Today s lecture What, exactly, is the relational data model? What are

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

Chapter 4: SQL. Basic Structure

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

More information

Why SQL? SQL is a very-high-level language. Database management system figures out best way to execute query

Why SQL? SQL is a very-high-level language. Database management system figures out best way to execute query Basic SQL Queries 1 Why SQL? SQL is a very-high-level language Say what to do rather than how to do it Avoid a lot of data-manipulation details needed in procedural languages like C++ or Java Database

More information

SQL. The Basics Advanced Manipulation Constraints Authorization 1. 1

SQL. The Basics Advanced Manipulation Constraints Authorization 1. 1 SQL The Basics Advanced Manipulation Constraints Authorization 1. 1 Table of Contents SQL 0 Table of Contents 0/1 Parke Godfrey 0/2 Acknowledgments 0/3 SQL: a standard language for accessing databases

More information

Missing Information. We ve assumed every tuple has a value for every attribute. But sometimes information is missing. Two common scenarios:

Missing Information. We ve assumed every tuple has a value for every attribute. But sometimes information is missing. Two common scenarios: NULL values Missing Information We ve assumed every tuple has a value for every attribute. But sometimes information is missing. Two common scenarios: Missing value. E.g., we know a student has some email

More information

Relational Algebra and SQL

Relational Algebra and SQL Relational Algebra and SQL Computer Science E-66 Harvard University David G. Sullivan, Ph.D. Example Domain: a University We ll use relations from a university database. four relations that store info.

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

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13 CS121 MIDTERM REVIEW CS121: Relational Databases Fall 2017 Lecture 13 2 Before We Start Midterm Overview 3 6 hours, multiple sittings Open book, open notes, open lecture slides No collaboration Possible

More information

Announcements (September 14) SQL: Part I SQL. Creating and dropping tables. Basic queries: SFW statement. Example: reading a table

Announcements (September 14) SQL: Part I SQL. Creating and dropping tables. Basic queries: SFW statement. Example: reading a table Announcements (September 14) 2 SQL: Part I Books should have arrived by now Homework #1 due next Tuesday Project milestone #1 due in 4 weeks CPS 116 Introduction to Database Systems SQL 3 Creating and

More information

Introduction to SQL SELECT-FROM-WHERE STATEMENTS SUBQUERIES DATABASE SYSTEMS AND CONCEPTS, CSCI 3030U, UOIT, COURSE INSTRUCTOR: JAREK SZLICHTA

Introduction to SQL SELECT-FROM-WHERE STATEMENTS SUBQUERIES DATABASE SYSTEMS AND CONCEPTS, CSCI 3030U, UOIT, COURSE INSTRUCTOR: JAREK SZLICHTA Introduction to SQL SELECT-FROM-WHERE STATEMENTS MULTIRELATION QUERIES SUBQUERIES 1 SQL SQL is a standard language for accessing databases. SQL stands for Structured Query Language. SQL lecture s material

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

Today s topics. Null Values. Nulls and Views in SQL. Standard Boolean 2-valued logic 9/5/17. 2-valued logic does not work for nulls

Today s topics. Null Values. Nulls and Views in SQL. Standard Boolean 2-valued logic 9/5/17. 2-valued logic does not work for nulls Today s topics CompSci 516 Data Intensive Computing Systems Lecture 4 Relational Algebra and Relational Calculus Instructor: Sudeepa Roy Finish NULLs and Views in SQL from Lecture 3 Relational Algebra

More information

Part I: Structured Data

Part I: Structured Data Inf1-DA 2011 2012 I: 92 / 117 Part I Structured Data Data Representation: I.1 The entity-relationship (ER) data model I.2 The relational model Data Manipulation: I.3 Relational algebra I.4 Tuple-relational

More information

Relational Algebra and SQL

Relational Algebra and SQL Relational Algebra and SQL Relational Algebra. This algebra is an important form of query language for the relational model. The operators of the relational algebra: divided into the following classes:

More information

SQL QUERIES. CS121: Relational Databases Fall 2017 Lecture 5

SQL QUERIES. CS121: Relational Databases Fall 2017 Lecture 5 SQL QUERIES CS121: Relational Databases Fall 2017 Lecture 5 SQL Queries 2 SQL queries use the SELECT statement General form is: SELECT A 1, A 2,... FROM r 1, r 2,... WHERE P; r i are the relations (tables)

More information

DATABASE TECHNOLOGY - 1MB025

DATABASE TECHNOLOGY - 1MB025 1 DATABASE TECHNOLOGY - 1MB025 Fall 2004 An introductory course on database systems http://user.it.uu.se/~udbl/dbt-ht2004/ alt. http://www.it.uu.se/edu/course/homepage/dbastekn/ht04/ Kjell Orsborn Uppsala

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

DATABASTEKNIK - 1DL116

DATABASTEKNIK - 1DL116 1 DATABASTEKNIK - 1DL116 Spring 2004 An introductury course on database systems http://user.it.uu.se/~udbl/dbt-vt2004/ Kjell Orsborn Uppsala Database Laboratory Department of Information Technology, Uppsala

More information

Silberschatz, Korth and Sudarshan See for conditions on re-use

Silberschatz, Korth and Sudarshan See   for conditions on re-use Chapter 3: SQL Database System Concepts, 5th Ed. See www.db-book.com for conditions on re-use Chapter 3: SQL Data Definition Basic Query Structure Set Operations Aggregate Functions Null Values Nested

More information

Chapter 3: SQL. Chapter 3: SQL

Chapter 3: SQL. Chapter 3: SQL Chapter 3: SQL Database System Concepts, 5th Ed. See www.db-book.com for conditions on re-use Chapter 3: SQL Data Definition Basic Query Structure Set Operations Aggregate Functions Null Values Nested

More information

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries. Slides are reused by the approval of Jeffrey Ullman s

Introduction to SQL. Select-From-Where Statements Multirelation Queries Subqueries. Slides are reused by the approval of Jeffrey Ullman s Introduction to SQL Select-From-Where Statements Multirelation Queries Subqueries Slides are reused by the approval of Jeffrey Ullman s 1 Why SQL? SQL is a very-high-level language. Say what to do rather

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and

More information

Information Systems Engineering. SQL Structured Query Language DML Data Manipulation (sub)language

Information Systems Engineering. SQL Structured Query Language DML Data Manipulation (sub)language Information Systems Engineering SQL Structured Query Language DML Data Manipulation (sub)language 1 DML SQL subset for data manipulation (DML) includes four main operations SELECT - used for querying a

More information

RELATIONAL ALGEBRA II. CS121: Relational Databases Fall 2017 Lecture 3

RELATIONAL ALGEBRA II. CS121: Relational Databases Fall 2017 Lecture 3 RELATIONAL ALGEBRA II CS121: Relational Databases Fall 2017 Lecture 3 Last Lecture 2 Query languages provide support for retrieving information from a database Introduced the relational algebra A procedural

More information

Databases Relational algebra Lectures for mathematics students

Databases Relational algebra Lectures for mathematics students Databases Relational algebra Lectures for mathematics students March 5, 2017 Relational algebra Theoretical model for describing the semantics of relational databases, proposed by T. Codd (who authored

More information

Chapter 3: SQL. Database System Concepts, 5th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

Chapter 3: SQL. Database System Concepts, 5th Ed. Silberschatz, Korth and Sudarshan See  for conditions on re-use Chapter 3: SQL Database System Concepts, 5th Ed. See www.db-book.com for conditions on re-use Chapter 3: SQL Data Definition Basic Query Structure Set Operations Aggregate Functions Null Values Nested

More information

Relational Algebra. Procedural language Six basic operators

Relational Algebra. Procedural language Six basic operators Relational algebra Relational Algebra Procedural language Six basic operators select: σ project: union: set difference: Cartesian product: x rename: ρ The operators take one or two relations as inputs

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

SQL functions fit into two broad categories: Data definition language Data manipulation language

SQL functions fit into two broad categories: Data definition language Data manipulation language Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition Chapter 7 Beginning Structured Query Language (SQL) MDM NUR RAZIA BINTI MOHD SURADI 019-3932846 razia@unisel.edu.my

More information

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas SQL SQL Functionality stands for Structured Query Language sometimes pronounced sequel a very-high-level (declarative) language user specifies what is wanted, not how to find it number of standards original

More information

DATABASE TECHNOLOGY - 1MB025

DATABASE TECHNOLOGY - 1MB025 1 DATABASE TECHNOLOGY - 1MB025 Fall 2005 An introductury course on database systems http://user.it.uu.se/~udbl/dbt-ht2005/ alt. http://www.it.uu.se/edu/course/homepage/dbastekn/ht05/ Kjell Orsborn Uppsala

More information

Structured Query Language Continued. Rose-Hulman Institute of Technology Curt Clifton

Structured Query Language Continued. Rose-Hulman Institute of Technology Curt Clifton Structured Query Language Continued Rose-Hulman Institute of Technology Curt Clifton The Story Thus Far SELECT FROM WHERE SELECT * SELECT Foo AS Bar SELECT expression SELECT FROM WHERE LIKE SELECT FROM

More information

Introduction to SQL Part 2 by Michael Hahsler Based on slides for CS145 Introduction to Databases (Stanford)

Introduction to SQL Part 2 by Michael Hahsler Based on slides for CS145 Introduction to Databases (Stanford) Introduction to SQL Part 2 by Michael Hahsler Based on slides for CS145 Introduction to Databases (Stanford) Lecture 3 Lecture Overview 1. Aggregation & GROUP BY 2. Set operators & nested queries 3. Advanced

More information

CS143: Relational Model

CS143: Relational Model CS143: Relational Model Book Chapters (4th) Chapters 1.3-5, 3.1, 4.11 (5th) Chapters 1.3-7, 2.1, 3.1-2, 4.1 (6th) Chapters 1.3-6, 2.105, 3.1-2, 4.5 Things to Learn Data model Relational model Database

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Course 20761A: Querying Data with Transact-SQL Page 1 of 5 Querying Data with Transact-SQL Course 20761A: 2 days; Instructor-Led Introduction The main purpose of this 2 day instructor led course is to

More information

CSC 261/461 Database Systems Lecture 5. Fall 2017

CSC 261/461 Database Systems Lecture 5. Fall 2017 CSC 261/461 Database Systems Lecture 5 Fall 2017 MULTISET OPERATIONS IN SQL 2 UNION SELECT R.A FROM R, S WHERE R.A=S.A UNION SELECT R.A FROM R, T WHERE R.A=T.A Q 1 Q 2 r. A r. A = s. A r. A r. A = t. A}

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

Chapter 6 The database Language SQL as a tutorial

Chapter 6 The database Language SQL as a tutorial Chapter 6 The database Language SQL as a tutorial About SQL SQL is a standard database language, adopted by many commercial systems. ANSI SQL, SQL-92 or SQL2, SQL99 or SQL3 extends SQL2 with objectrelational

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

Database Management

Database Management Database Management - 2011 Model Answers 1. a. A data model should comprise a structural part, an integrity part and a manipulative part. The relational model provides standard definitions for all three

More information

Databasesystemer, forår 2006 IT Universitetet i København. Forelæsning 9: Mere om SQL. 30. marts Forelæser: Esben Rune Hansen

Databasesystemer, forår 2006 IT Universitetet i København. Forelæsning 9: Mere om SQL. 30. marts Forelæser: Esben Rune Hansen Databasesystemer, forår 2006 IT Universitetet i København Forelæsning 9: Mere om SQL 30. marts 2006 Forelæser: Esben Rune Hansen Today s lecture Subqueries in SQL. Set operators in SQL. Security and authorization

More information

Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries Derived Relations Views Modification of the Database Data Definition

Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries Derived Relations Views Modification of the Database Data Definition Chapter 4: SQL Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries Derived Relations Views Modification of the Database Data Definition Language 4.1 Schema Used in Examples

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

SQL Data Querying and Views

SQL Data Querying and Views Course A7B36DBS: Database Systems Lecture 04: SQL Data Querying and Views Martin Svoboda Faculty of Electrical Engineering, Czech Technical University in Prague Outline SQL Data manipulation SELECT queries

More information

Relational Database: The Relational Data Model; Operations on Database Relations

Relational Database: The Relational Data Model; Operations on Database Relations Relational Database: The Relational Data Model; Operations on Database Relations Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin Overview

More information

MariaDB Crash Course. A Addison-Wesley. Ben Forta. Upper Saddle River, NJ Boston. Indianapolis. Singapore Mexico City. Cape Town Sydney.

MariaDB Crash Course. A Addison-Wesley. Ben Forta. Upper Saddle River, NJ Boston. Indianapolis. Singapore Mexico City. Cape Town Sydney. MariaDB Crash Course Ben Forta A Addison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid Cape Town Sydney Tokyo Singapore Mexico City

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 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

Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761)

Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761) Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761) Course Length: 3 days Course Delivery: Traditional Classroom Online Live MOC on Demand Course Overview The main purpose of this

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

Set Operations, Union

Set Operations, Union Set Operations, Union The common set operations, union, intersection, and difference, are available in SQL. The relation operands must be compatible in the sense that they have the same attributes (same

More information

Lecture 3 SQL - 2. Today s topic. Recap: Lecture 2. Basic SQL Query. Conceptual Evaluation Strategy 9/3/17. Instructor: Sudeepa Roy

Lecture 3 SQL - 2. Today s topic. Recap: Lecture 2. Basic SQL Query. Conceptual Evaluation Strategy 9/3/17. Instructor: Sudeepa Roy CompSci 516 Data Intensive Computing Systems Lecture 3 SQL - 2 Instructor: Sudeepa Roy Announcements HW1 reminder: Due on 09/21 (Thurs), 11:55 pm, no late days Project proposal reminder: Due on 09/20 (Wed),

More information

Carnegie Mellon Univ. Dept. of Computer Science Database Applications. General Overview - rel. model. Overview - detailed - SQL

Carnegie Mellon Univ. Dept. of Computer Science Database Applications. General Overview - rel. model. Overview - detailed - SQL Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications Faloutsos Lecture#6: Rel. model - SQL part1 General Overview - rel. model Formal query languages rel algebra and calculi Commercial

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management Tenth Edition Chapter 8 Advanced SQL SQL Join Operators Join operation merges rows from two tables and returns the rows with one of the following:

More information

Why Relational Databases? Relational databases allow for the storage and analysis of large amounts of data.

Why Relational Databases? Relational databases allow for the storage and analysis of large amounts of data. DATA 301 Introduction to Data Analytics Relational Databases Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca DATA 301: Data Analytics (2) Why Relational Databases? Relational

More information

20461: Querying Microsoft SQL Server 2014 Databases

20461: Querying Microsoft SQL Server 2014 Databases Course Outline 20461: Querying Microsoft SQL Server 2014 Databases Module 1: Introduction to Microsoft SQL Server 2014 This module introduces the SQL Server platform and major tools. It discusses editions,

More information

SQL Overview. CSCE 315, Fall 2017 Project 1, Part 3. Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch

SQL Overview. CSCE 315, Fall 2017 Project 1, Part 3. Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch SQL Overview CSCE 315, Fall 2017 Project 1, Part 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch SQL Structured Query Language Database language used to manage and query relational

More information

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects.

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects. Set Theory Set theory is a branch of mathematics that studies sets. Sets are a collection of objects. Often, all members of a set have similar properties, such as odd numbers less than 10 or students in

More information

Lecture 6 - More SQL

Lecture 6 - More SQL CMSC 461, Database Management Systems Spring 2018 Lecture 6 - More SQL These slides are based on Database System Concepts book and slides, 6, and the 2009/2012 CMSC 461 slides by Dr. Kalpakis Dr. Jennifer

More information

SQL: Data Querying. B0B36DBS, BD6B36DBS: Database Systems. h p://www.ksi.m.cuni.cz/~svoboda/courses/172-b0b36dbs/ Lecture 4

SQL: Data Querying. B0B36DBS, BD6B36DBS: Database Systems. h p://www.ksi.m.cuni.cz/~svoboda/courses/172-b0b36dbs/ Lecture 4 B0B36DBS, BD6B36DBS: Database Systems h p://www.ksi.m.cuni.cz/~svoboda/courses/172-b0b36dbs/ Lecture 4 SQL: Data Querying Mar n Svoboda mar n.svoboda@fel.cvut.cz 20. 3. 2018 Czech Technical University

More information

618 Index. BIT data type, 108, 109 BIT_LENGTH, 595f BIT VARYING data type, 108 BLOB data type, 108 Boolean data type, 109

618 Index. BIT data type, 108, 109 BIT_LENGTH, 595f BIT VARYING data type, 108 BLOB data type, 108 Boolean data type, 109 Index A abbreviations in field names, 22 in table names, 31 Access. See under Microsoft acronyms in field names, 22 in table names, 31 aggregate functions, 74, 375 377, 416 428. See also AVG; COUNT; COUNT(*);

More information

RAQUEL s Relational Operators

RAQUEL s Relational Operators Contents RAQUEL s Relational Operators Introduction 2 General Principles 2 Operator Parameters 3 Ordinary & High-Level Operators 3 Operator Valency 4 Default Tuples 5 The Relational Algebra Operators in

More information

Applied Databases. Sebastian Maneth. Lecture 7 Simple SQL Queries. University of Edinburgh - February 1 st, 2016

Applied Databases. Sebastian Maneth. Lecture 7 Simple SQL Queries. University of Edinburgh - February 1 st, 2016 Applied Databases Lecture 7 Simple SQL Queries Sebastian Maneth University of Edinburgh - February 1 st, 2016 Outline 2 1. Structured Querying Language (SQL) 2. Creating Tables 3. Simple SQL queries SQL

More information

Using Relational Databases for Digital Research

Using Relational Databases for Digital Research Using Relational Databases for Digital Research Definition (using a) relational database is a way of recording information in a structure that maximizes efficiency by separating information into different

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

CSCB20 Week 4. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017

CSCB20 Week 4. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017 CSCB20 Week 4 Introduction to Database and Web Application Programming Anna Bretscher Winter 2017 Last Week Intro to SQL and MySQL Mapping Relational Algebra to SQL queries Focused on queries to start

More information

Nested Queries. Dr Paolo Guagliardo. Aggregate results in WHERE The right way. Fall 2018

Nested Queries. Dr Paolo Guagliardo. Aggregate results in WHERE The right way. Fall 2018 Nested Queries Dr Paolo Guagliardo dbs-lecturer@ed.ac.uk Fall 2018 Aggregate results in WHERE The right way Account Number Branch CustID Balance 111 London 1 1330.00 222 London 2 1756.00 333 Edinburgh

More information

4. SQL - the Relational Database Language Standard 4.3 Data Manipulation Language (DML)

4. SQL - the Relational Database Language Standard 4.3 Data Manipulation Language (DML) Since in the result relation each group is represented by exactly one tuple, in the select clause only aggregate functions can appear, or attributes that are used for grouping, i.e., that are also used

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

Chapter # 7 Introduction to Structured Query Language (SQL) Part II

Chapter # 7 Introduction to Structured Query Language (SQL) Part II Chapter # 7 Introduction to Structured Query Language (SQL) Part II Updating Table Rows UPDATE Modify data in a table Basic Syntax: UPDATE tablename SET columnname = expression [, columnname = expression]

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

The SQL database language Parts of the SQL language

The SQL database language Parts of the SQL language DATABASE DESIGN I - 1DL300 Fall 2011 Introduction to SQL Elmasri/Navathe ch 4,5 Padron-McCarthy/Risch ch 7,8,9 An introductory course on database systems http://www.it.uu.se/edu/course/homepage/dbastekn/ht11

More information

Administrivia. The Relational Model. Review. Review. Review. Some useful terms

Administrivia. The Relational Model. Review. Review. Review. Some useful terms Administrivia The Relational Model Ramakrishnan & Gehrke Chapter 3 Homework 0 is due next Thursday No discussion sections next Monday (Labor Day) Enrollment goal ~150, 118 currently enrolled, 47 on the

More information

Relational Algebra and SQL. Basic Operations Algebra of Bags

Relational Algebra and SQL. Basic Operations Algebra of Bags Relational Algebra and SQL Basic Operations Algebra of Bags 1 What is an Algebra Mathematical system consisting of: Operands --- variables or values from which new values can be constructed. Operators

More information

SQL. CS 564- Fall ACKs: Dan Suciu, Jignesh Patel, AnHai Doan

SQL. CS 564- Fall ACKs: Dan Suciu, Jignesh Patel, AnHai Doan SQL CS 564- Fall 2015 ACKs: Dan Suciu, Jignesh Patel, AnHai Doan MOTIVATION The most widely used database language Used to query and manipulate data SQL stands for Structured Query Language many SQL standards:

More information

Relational Query Languages: Relational Algebra. Juliana Freire

Relational Query Languages: Relational Algebra. Juliana Freire Relational Query Languages: Relational Algebra Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports simple, powerful QLs: Simple

More information

After completing this course, participants will be able to:

After completing this course, participants will be able to: Querying SQL Server T h i s f i v e - d a y i n s t r u c t o r - l e d c o u r s e p r o v i d e s p a r t i c i p a n t s w i t h t h e t e c h n i c a l s k i l l s r e q u i r e d t o w r i t e b a

More information

SQL STRUCTURED QUERY LANGUAGE

SQL STRUCTURED QUERY LANGUAGE STRUCTURED QUERY LANGUAGE SQL Structured Query Language 4.1 Introduction Originally, SQL was called SEQUEL (for Structured English QUery Language) and implemented at IBM Research as the interface for an

More information

Querying Microsoft SQL Server 2012/2014

Querying Microsoft SQL Server 2012/2014 Page 1 of 14 Overview This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL queries for Microsoft SQL Server 2014. This course is the foundation

More information

QUERYING MICROSOFT SQL SERVER COURSE OUTLINE. Course: 20461C; Duration: 5 Days; Instructor-led

QUERYING MICROSOFT SQL SERVER COURSE OUTLINE. Course: 20461C; Duration: 5 Days; Instructor-led CENTER OF KNOWLEDGE, PATH TO SUCCESS Website: QUERYING MICROSOFT SQL SERVER Course: 20461C; Duration: 5 Days; Instructor-led WHAT YOU WILL LEARN This 5-day instructor led course provides students with

More information

Multisets and Duplicates. SQL: Duplicate Semantics and NULL Values. How does this impact Queries?

Multisets and Duplicates. SQL: Duplicate Semantics and NULL Values. How does this impact Queries? Multisets and Duplicates SQL: Duplicate Semantics and NULL Values Fall 2015 SQL uses a MULTISET/BAG semantics rather than a SET semantics: SQL tables are multisets of tuples originally for efficiency reasons

More information

Chapter 6: Formal Relational Query Languages

Chapter 6: Formal Relational Query Languages Chapter 6: Formal Relational Query Languages Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 6: Formal Relational Query Languages Relational Algebra Tuple Relational

More information