Relational model and basic SQL
|
|
- Randell Bates
- 5 years ago
- Views:
Transcription
1 Relational model and basic SQL Introduction to Database Design 2011, Lecture 2 Relational model and keys Basic SQL - Creating tables - Inserting rows - Retrieving information - Joins Overview 2
2 Relational databases A logical view of databases, due to E. F. Codd, 1970 Data stored in tables (aka relations) columns (aka attributes) rows (aka tuples) 3 Basic terminology A relation schema is a set of attributes A database schema is a set table names along with corresponding relation schemas A relation instance is a relation schema and a set of tuples 4
3 A candidate key is minimal set of attributes that characterises tuples uniquely A primary key is a chosen candidate key In the instructor table ID is the primary key Keys 5 Composite primary keys Primary keys can consist of more than one attribute Table: classroom building room_number capacity Packard Painter Taylor Watson Watson Primary key consists of building and room_number 6
4 Foreign keys are references to other tables primary keys The instructor table The department table 7 Notation for schemas instructor (ID, name, dept_name, salary) department (dept_name, building, budget) classroom (building, room_number, capacity) 8
5 Schema diagrams 9 SQL
6 Structured Query Language SQL SQL used for many purposes - as a data definition language for defining database schemas - as a data manipulation language for manipulating data - as a query language for retrieving data 11 Data definition in SQL create table instructor! (ID!! varchar(5),! name!!! varchar(20),! dept_name varchar(20),! salary!! numeric(8,2),! primary key (ID),! foreign key (dept_name) references department); create table department! (dept_name varchar(20),! building!! varchar(15),! budget!! numeric(12,2),! primary key (dept_name)); create table classroom! (building!! varchar(15),! room_number!varchar(7),! capacity!! numeric(4,0),! primary key (building, room_number)); 12
7 Foreign keys in MySQL On ITU s MySQL system, the standard engine does not enforce primary keys InnoDB does create table instructor! (ID!!! varchar(5),! name!! varchar(20), dept_name varchar(20),! salary!! numeric(8,2),! primary key (ID),! foreign key (dept_name) references department(dept_name)) ENGINE = InnoDB; create table department! (dept_name varchar(20),! building! varchar(15),! budget!! numeric(12,2),! primary key (dept_name)) ENGINE = InnoDB; Note also, here name of key attribute is specified 13 SQL types SQL type Describes Example int Integers 12 numeric(12,2) decimal number 12,34 varchar(40) text Volvo text text, no size limit Volvo date date time time 09:30 datetime date and time :30 14
8 Inserting one row Inserting many rows Data manipulation in SQL insert into department values ('Biology', 'Watson', '90000'); insert into department values ('Biology', 'Watson', '90000'), ('History', 'Painter', '50000'); Inserts may not break uniqueness constraint for primary keys Alternative syntax insert into department (dept_name, building, budget) values ('Biology', 'Watson', '90000'), ('History', 'Painter', '50000'); 15 Deleting all rows Data manipulation in SQL delete from department; Can also be modified to delete only certain rows Deleting rows and schema drop table department; 16
9 Queries: retrieving information Queries in SQL mysql> select * from classroom; building room_number capacity Packard Painter Taylor Watson Watson rows in set (0.00 sec) 18
10 Queries in SQL mysql> select building, room_number from classroom; building room_number Packard 101 Painter 514 Taylor 3128 Watson 101 Watson rows in set (0.01 sec) 19 Queries in SQL mysql> select building from classroom; building Packard Painter Taylor Watson Watson 5 rows in set (0.01 sec) 20
11 Queries in SQL mysql> select * from classroom where building = 'Watson'; building room_number capacity Watson Watson rows in set (0.00 sec) 21 Queries in SQL mysql> select room_number from classroom where building = 'Watson'; room_number rows in set (0.00 sec) 22
12 Projection in the relational model Projecting on name and salary select name, salary from instructor; 23 Selection in the relational model select * from instructor where salary > 90000; 24
13 Combining selection and projection select name, dept_name from instructor where salary > 90000; First select, then project 25 Operations in the relational model Selection and projection take tables and return tables But result may contain duplicates select dept_name from instructor; 26
14 Can repair this by using keyword distinct Distinct mysql> select dept_name from instructor; dept_name Biology Comp. Sci. Comp. Sci. Comp. Sci. Elec. Eng. Finance Finance History History Music Physics Physics rows in set (0.00 sec) mysql> select distinct dept_name from instructor; dept_name Biology Comp. Sci. Elec. Eng. Finance History Music Physics rows in set (0.00 sec) 27 Selecting on combinations of features mysql> select name from instructor -> where salary > > and dept_name = "Physics"; name Einstein 1 row in set (0.00 sec) mysql> select name from instructor -> where salary > > or dept_name = "Physics"; name Einstein Gold Brandt 3 rows in set (0.00 sec) 28
15 Joins Queries on multiple relations Recall mysql> select * from instructor; ID name dept_name salary Srinivasan Comp. Sci Wu Finance Mozart Music Einstein Physics El Said History Gold Physics Katz Comp. Sci Califieri History Singh Finance Crick Biology Brandt Comp. Sci Kim Elec. Eng rows in set (0.00 sec) mysql> select * from department; dept_name building budget Biology Watson Comp. Sci. Taylor Elec. Eng. Taylor Finance Painter History Painter Music Packard Physics Watson rows in set (0.00 sec) 30
16 Queries on multiple relations mysql> select * from instructor, department; ID name dept_name salary dept_name building budget Srinivasan Comp. Sci Biology Watson Srinivasan Comp. Sci Comp. Sci. Taylor Srinivasan Comp. Sci Elec. Eng. Taylor Srinivasan Comp. Sci Finance Painter Srinivasan Comp. Sci History Painter Srinivasan Comp. Sci Music Packard Srinivasan Comp. Sci Physics Watson Wu Finance Biology Watson Wu Finance Comp. Sci. Taylor Wu Finance Elec. Eng. Taylor Wu Finance Finance Painter Wu Finance History Painter Wu Finance Music Packard Wu Finance Physics Watson Mozart Music Biology Watson Mozart Music Comp. Sci. Taylor Mozart Music Elec. Eng. Taylor Mozart Music Finance Painter Mozart Music History Painter rows in set (0.01 sec) 31 Joining relations mysql> select * from instructor, department -> where instructor.dept_name = department.dept_name; ID name dept_name salary dept_name building budget Srinivasan Comp. Sci Comp. Sci. Taylor Wu Finance Finance Painter Mozart Music Music Packard Einstein Physics Physics Watson El Said History History Painter Gold Physics Physics Watson Katz Comp. Sci Comp. Sci. Taylor Califieri History History Painter Singh Finance Finance Painter Crick Biology Biology Watson Brandt Comp. Sci Comp. Sci. Taylor Kim Elec. Eng Elec. Eng. Taylor rows in set (0.00 sec) 32
17 Natural join mysql> select * from instructor natural join department; dept_name ID name salary building budget Comp. Sci Srinivasan Taylor Finance Wu Painter Music Mozart Packard Physics Einstein Watson History El Said Painter Physics Gold Watson Comp. Sci Katz Taylor History Califieri Painter Finance Singh Painter Biology Crick Watson Comp. Sci Brandt Taylor Elec. Eng Kim Taylor rows in set (0.01 sec) Natural join compares column names Does not depend on foreign keys 33 First compute cartesian product The select only matching tuples Natural joins operationally mysql> select * from instructor natural join department; Finally project to get rid of duplicate attributes 34
18 Selecting on natural joins mysql> select * from instructor natural join department -> where salary > 70000; dept_name ID name salary building budget Biology Crick Watson Comp. Sci Katz Taylor Comp. Sci Brandt Taylor Elec. Eng Kim Taylor Finance Wu Painter Finance Singh Painter Physics Einstein Watson Physics Gold Watson rows in set (0,00 sec) 35 Example Find all students whose advisors make more than $70000 Best advise I can give: - Start by solving an easier problem - Try to gather all the information needed first 36
19 Example mysql> select * from advisor; s_id i_id mysql> select * from student join advisor on student.id = s_id; ID name dept_name tot_cred s_id i_id Shankar Comp. Sci Peltier Physics Levy Physics Zhang Comp. Sci Brown Comp. Sci Chavez Finance Tanaka Biology Aoi Elec. Eng Bourikas Elec. Eng rows in set (0,00 sec) 37 Example mysql> select * from (student join advisor on student.id = s_id) join instructor on i_id = instructor.id; ID name dept_name tot_cred s_id i_id ID name dept_name salary Shankar Comp. Sci Srinivasan Comp. Sci Peltier Physics Einstein Physics Levy Physics Einstein Physics Zhang Comp. Sci Katz Comp. Sci Brown Comp. Sci Katz Comp. Sci Chavez Finance Singh Finance Tanaka Biology Crick Biology Aoi Elec. Eng Kim Elec. Eng Bourikas Elec. Eng Kim Elec. Eng rows in set (0,00 sec) mysql> select student.name -> from (student join advisor on student.id = s_id) join instructor on i_id = instructor.id -> where salary > 70000; name Peltier Levy Zhang Brown Chavez Tanaka Aoi Bourikas 8 rows in set (0,00 sec) 38
20 Example, alternative solution mysql> select * from student, advisor, instructor where student.id = s_id and instructor.id = i_id; ID name dept_name tot_cred s_id i_id ID name dept_name salary Shankar Comp. Sci Srinivasan Comp. Sci Peltier Physics Einstein Physics Levy Physics Einstein Physics Zhang Comp. Sci Katz Comp. Sci Brown Comp. Sci Katz Comp. Sci Chavez Finance Singh Finance Tanaka Biology Crick Biology Aoi Elec. Eng Kim Elec. Eng Bourikas Elec. Eng Kim Elec. Eng rows in set (0,01 sec) mysql> select student.name from student, advisor, instructor -> where student.id = s_id and instructor.id = i_id -> and salary > 70000; name Peltier Levy Zhang Brown Chavez Tanaka Aoi Bourikas 8 rows in set (0,00 sec) 39 Suppose we want to find all information on courses and their prerequisites Renaming mysql> select * from prereq; course_id prereq_id BIO-301 BIO-101 BIO-399 BIO-101 CS-190 CS-101 CS-315 CS-101 CS-319 CS-101 CS-347 CS-101 EE-181 PHY rows in set (0,00 sec) mysql> select * from course; course_id title dept_name credits BIO-101 Intro. to Biology Biology 4 BIO-301 Genetics Biology 4 BIO-399 Computational Biology Biology 3 CS-101 Intro. to Computer Science Comp. Sci. 4 CS-190 Game Design Comp. Sci. 4 CS-315 Robotics Comp. Sci. 3 CS-319 Image Processing Comp. Sci. 3 CS-347 Database System Concepts Comp. Sci. 3 EE-181 Intro. to Digital Systems Elec. Eng. 3 FIN-201 Investment Banking Finance 3 HIS-351 World History History 3 MU-199 Music Video Production Music 3 PHY-101 Physical Principles Physics rows in set (0,00 sec) 40
21 Renaming mysql> select * from course natural join prereq; course_id title dept_name credits prereq_id BIO-301 Genetics Biology 4 BIO-101 BIO-399 Computational Biology Biology 3 BIO-101 CS-190 Game Design Comp. Sci. 4 CS-101 CS-315 Robotics Comp. Sci. 3 CS-101 CS-319 Image Processing Comp. Sci. 3 CS-101 CS-347 Database System Concepts Comp. Sci. 3 CS-101 EE-181 Intro. to Digital Systems Elec. Eng. 3 PHY rows in set (0,00 sec) mysql> mysql> select * from (course natural join prereq) join course on course_id = prereq_id; ERROR 1066 (42000): Not unique table/alias: 'course' mysql> select * from (course natural join prereq) join course as pre on pre.course_id = prereq_id; course_id title dept_name credits prereq_id course_id title dept_name credits BIO-301 Genetics Biology 4 BIO-101 BIO-101 Intro. to Biology Biology 4 BIO-399 Computational Biology Biology 3 BIO-101 BIO-101 Intro. to Biology Biology 4 CS-190 Game Design Comp. Sci. 4 CS-101 CS-101 Intro. to Computer Science Comp. Sci. 4 CS-315 Robotics Comp. Sci. 3 CS-101 CS-101 Intro. to Computer Science Comp. Sci. 4 CS-319 Image Processing Comp. Sci. 3 CS-101 CS-101 Intro. to Computer Science Comp. Sci. 4 CS-347 Database System Concepts Comp. Sci. 3 CS-101 CS-101 Intro. to Computer Science Comp. Sci. 4 EE-181 Intro. to Digital Systems Elec. Eng. 3 PHY-101 PHY-101 Physical Principles Physics rows in set (0,00 sec) 41 Renaming Suppose we want names of departments with budget larger than biology mysql> select * from department; dept_name building budget Biology Watson Comp. Sci. Taylor Elec. Eng. Taylor Finance Painter History Painter Music Packard Physics Watson rows in set (0.00 sec) This doesn t quite work: select dept_name from department, department where budget > budget and dept_name = "Biology"; 42
22 Renaming We need two copies of department, and they need different names mysql> select T.dept_name -> from department as T, department as S -> where T.budget > S.budget -> and S.dept_name = "Biology"; dept_name Comp. Sci. Finance rows in set (0.00 sec) 43 After this week you should Understand concepts of primary and foreign keys Be able to draw schema diagrams Be able to write SQL statements using - create table - insert into - select from... where Explain meaning of simple queries using relational model 44
CSCB20 Week 2. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017
CSCB20 Week 2 Introduction to Database and Web Application Programming Anna Bretscher Winter 2017 This Week Quick Review of terminology Relational Model Continued Relational diagrams Relational operations
More informationCSCB20. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017
CSCB20 Introduction to Database and Web Application Programming Anna Bretscher Winter 2017 Welcome to CSCB20 Course Description: A practical introduction to databases and Web app development. Databases:
More informationCSCB20 Week 3. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017
CSCB20 Week 3 Introduction to Database and Web Application Programming Anna Bretscher Winter 2017 This Week Intro to SQL and MySQL Mapping Relational Algebra to SQL queries We will focus on queries to
More informationLecture 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 informationMySQL Views & Comparing SQL to NoSQL
CMSC 461, Database Management Systems Fall 2014 MySQL Views & Comparing SQL to NoSQL These slides are based on Database System Concepts book and slides, 6 th edition, and the 2009/2012 CMSC 461 slides
More informationCSCB20 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 informationOther Relational Languages
Other Relational Languages 1 Tuple Relational Calculus A nonprocedural query language, where each query is of the form {t P (t ) } It is the set of all tuples t such that predicate P is true for t t is
More informationThe En'ty Rela'onship Model
The En'ty Rela'onship Model Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata Slides re-used, with minor modification, from Silberschatz, Korth and Sudarshan www.db-book.com Outline
More informationChapter 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 informationChapter 7: Entity-Relationship Model. Chapter 7: Entity-Relationship Model
Chapter 7: Entity-Relationship Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 7: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram
More informationIndexing: B + -Tree. CS 377: Database Systems
Indexing: B + -Tree CS 377: Database Systems Recap: Indexes Data structures that organize records via trees or hashing Speed up search for a subset of records based on values in a certain field (search
More informationChapter 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 informationCS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model
CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model Modifies from: Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Textbook: Chapter 2 2.2 Example of a Relation
More informationThe 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 informationChapter 2 Introduction to Relational Models
CMSC 461, Database Management Systems Spring 2018 Chapter 2 Introduction to Relational Models These slides are based on Database System Concepts book and slides, 6th edition, and the 2009 CMSC 461 slides
More informationRelational 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 informationCS425 Fall 2013 Boris Glavic Chapter 7: Entity-Relationship Model!
CS425 Fall 2013 Boris Glavic Chapter 7: Entity-Relationship Model! Partially taken from! Klaus R. Dittrich! modified from:! Database System Concepts, 6 th Ed.! Silberschatz, Korth and Sudarshan See www.db-book.com
More informationChapter 11: Indexing and Hashing" Chapter 11: Indexing and Hashing"
Chapter 11: Indexing and Hashing" Database System Concepts, 6 th Ed.! Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-use " Chapter 11: Indexing and Hashing" Basic Concepts!
More informationChapter 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 informationChapter 4: Intermediate SQL
Chapter 4: Intermediate SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 4: Intermediate SQL Join Expressions Views Transactions Integrity Constraints SQL Data
More informationChapter 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 informationCS127 Homework #3. Due: October 11th, :59 P.M. Consider the following set of functional dependencies, F, for the schema R(A, B, C, D, E)
CS127 Homework #3 Warmup #1 Consider the following set of functional dependencies, F, for the schema R(A, B, C, D, E) 1. Find the candidate keys for the schema R. AB, C, D, and EA 2. Compute the closure,
More informationTextbook: Chapter 6! CS425 Fall 2013 Boris Glavic! Chapter 3: Formal Relational Query. Relational Algebra! Select Operation Example! Select Operation!
Chapter 3: Formal Relational Query Languages CS425 Fall 2013 Boris Glavic Chapter 3: Formal Relational Query Languages Relational Algebra Tuple Relational Calculus Domain Relational Calculus Textbook:
More informationChapter 4: Intermediate SQL
Chapter 4: Intermediate SQL Chapter 4: Intermediate SQL Join Expressions Views Transactions Integrity Constraints SQL Data Types and Schemas Authorization Joined Relations Join operations take two relations
More informationDebapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata
SQL 3 Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata Slides re-used, with minor modification, from Silberschatz, Korth and Sudarshan www.db-book.com Outline Join Expressions Views
More informationCS 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 informationQQ 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 informationExplain in words what this relational algebra expression returns:
QUIZ: Relational Algebra Explain in words what this relational algebra expression returns: A: The names of all customers who have accounts at both the Downtown and uptown branches 3.1 Practice Exercise
More informationCS425 Fall 2017 Boris Glavic Chapter 4: Introduction to SQL
CS425 Fall 2017 Boris Glavic Chapter 4: Introduction to SQL Modified from: Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 4: Introduction to SQL Overview of the
More informationCSC 343 Winter SQL: Aggregation, Joins, and Triggers MICHAEL LIUT
SQL: Aggregation, Joins, and Triggers CSC 343 Winter 2018 MICHAEL LIUT (MICHAEL.LIUT@UTORONTO.CA) DEPARTMENT OF MATHEMATICAL AND COMPUTATIONAL SCIENCES UNIVERSITY OF TORONTO MISSISSAUGA Aggregation Operators
More informationIntroduction CHAPTER. 1.1 Database-System Applications
CHAPTER 1 Introduction A database-management system (DBMS) is a collection of interrelated data and a set of programs to access those data. The collection of data, usually referred to as the database,
More informationPhysical Database Design
Physical Database Design These slides are mostly taken verbatim, or with minor changes, from those prepared by Stephen Hegner (http://www.cs.umu.se/ hegner/) of Umeå University Physical Database Design
More informationTextbook: Chapter 4. Chapter 5: Intermediate SQL. CS425 Fall 2016 Boris Glavic. Chapter 5: Intermediate SQL. View Definition.
Chapter 5: Intermediate SQL Views CS425 Fall 2013 Boris Glavic Chapter 5: Intermediate SQL Transactions Integrity Constraints SQL Data Types and Schemas Access Control Textbook: Chapter 4 5.2 Views View
More informationChapter 4: Intermediate SQL
Chapter 4: Intermediate SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use 4.1 Join Expressions Let s first review the joins from ch.3 4.2 1 SELECT * FROM student, takes
More informationCS425 Fall 2017 Boris Glavic Chapter 5: Intermediate SQL
CS425 Fall 2017 Boris Glavic Chapter 5: Intermediate SQL modified from: Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 5: Intermediate SQL Views Transactions Integrity
More informationERRATA for Database System Concepts, 6 th Edition, 2010 Silberschatz, Korth, and Sudarshan Last updated: December 6, 2010
ERRATA FOR FIRST PRINTING: ERRATA for Database System Concepts, 6 th Edition, 2010 Silberschatz, Korth, and Sudarshan Last updated: December 6, 2010 CHAPTER 3 1. Page 69, Figure 3.6: The department name
More informationSQL Retrieving Data from Multiple Tables
The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Database Lab (ECOM 4113) Lab 5 SQL Retrieving Data from Multiple Tables Eng. Ibraheem Lubbad An SQL JOIN clause is used
More informationChapter 7: Entity-Relationship Model
Chapter 7: Entity-Relationship Model, 7th Ed. See www.db-book.com for conditions on re-use Chapter 7: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity
More informationUnit1: Introduction. Database System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use
Unit1: Introduction Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Outline Introduction to Database Management Systems, Purpose of Database Systems, Database-System Applications,
More informationCS425 Midterm Exam Summer C 2012
Q1) List five responsibilities of a database-management system. Q2) Fill in the terms in the right hand side of the table that match the description from the list below: Instance SQL Integrity constraints
More informationDatabase index structures
Database index structures From: Database System Concepts, 6th edijon Avi Silberschatz, Henry Korth, S. Sudarshan McGraw- Hill Architectures for Massive DM D&K / UPSay 2015-2016 Ioana Manolescu 1 Chapter
More informationEntity-Relationship Model
Entity-Relationship Model Data Models High-level or conceptual data models provide concepts that are close to the way many users perceive data, whereas low-level or physical data models provide concepts
More informationUnit 2: SQL AND PL/SQL
Unit 2: SQL AND PL/SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Outline SQL: Characteristics and advantages, SQL Data Types and Literals, DDL, DML, DCL, TCL, SQL
More informationChapter 2: Relational Model
Chapter 2: Relational Model Chapter 2: Relational Model Structure of Relational Databases Fundamental Relational-Algebra-Operations Additional Relational-Algebra-Operations Extended Relational-Algebra-Operations
More informationChapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Example of a Relation attributes (or columns) tuples (or rows) 2.2 Attribute Types The
More informationChapter 7: Entity-Relationship Model
Chapter 7: Entity-Relationship Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 7: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram
More informationER to Relational Model. Professor Jessica Lin
ER to Relational Model Professor Jessica Lin 1 Reduction to Relation Schemas Entity sets and relationship sets can be expressed uniformly as relation schemas that represent the contents of the database.
More informationChapter 7: Entity-Relationship Model
Chapter 7: Entity-Relationship Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 7: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram
More informationRoadmap of This Lecture. Weak Entity Sets Extended E-R Features Reduction to Relation Schemas Database Design UML*
E-R Model (II) 1 Roadmap of This Lecture Weak Entity Sets Extended E-R Features Reduction to Relation Schemas Database Design UML* 2 Weak Entity Sets An entity set that does not have a primary key is referred
More informationChapter 1: Introduction
Chapter 1: Introduction Chapter 2: Intro. To the Relational Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Database Management System (DBMS) DBMS is Collection of
More informationChapter 7: Entity-Relationship Model
Chapter 7: Entity-Relationship Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 7: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram
More informationIndexing: Overview & Hashing. CS 377: Database Systems
Indexing: Overview & Hashing CS 377: Database Systems Recap: Data Storage Data items Records Memory DBMS Blocks blocks Files Different ways to organize files for better performance Disk Motivation for
More informationWHAT 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 informationChapter 6 Formal Relational Query Languages
CMSC 461, Database Management Systems Spring 2018 Chapter 6 Formal Relational Query Languages These slides are based on Database System Concepts book and slides, 6th edition, and the 2009/2012 CMSC 461
More informationNatural-Join Operation
Natural-Join Operation Natural join ( ) is a binary operation that is written as (r s) where r and s are relations. The result of the natural join is the set of all combinations of tuples in r and s that
More informationUnit I. By Prof.Sushila Aghav MIT
Unit I By Prof.Sushila Aghav MIT Introduction The Need for Databases Data Models Relational Databases Database Design Storage Manager Query Processing Transaction Manager DBMS Applications DBMS contains
More informationDatabase System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use
Chapter 11: Indexing and Hashing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files Static
More informationRelational Database Design (II)
Relational Database Design (II) 1 Roadmap of This Lecture Algorithms for Functional Dependencies (cont d) Decomposition Using Multi-valued Dependencies More Normal Form Database-Design Process Modeling
More informationPrinciples 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 informationChapter 11: Indexing and Hashing
Chapter 11: Indexing and Hashing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 11: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files B-Tree
More informationChapter 11: Indexing and Hashing
Chapter 11: Indexing and Hashing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 11: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files B-Tree
More informationInstructor: Amol Deshpande
Instructor: Amol Deshpande amol@cs.umd.edu } Storage and Query Processing Using ipython Notebook Indexes; Query Processing Basics } Other things Project 4: released Poll on Piazza Query Processing/Storage
More informationRelational Model. CSC 343 Winter 2018 MICHAEL LIUT
Relational Model CSC 343 Winter 2018 MICHAEL LIUT (MICHAEL.LIUT@UTORONTO.CA) DEPARTMENT OF MATHEMATICAL AND COMPUTATIONAL SCIENCES UNIVERSITY OF TORONTO MISSISSAUGA Administration Please email me your
More informationFinal Review. CS 377: Database Systems
Final Review CS 377: Database Systems Final Logistics May 3rd, 3:00-5:30 M 8 single-sided handwritten cheat sheets Comprehensive covering everything up to current class Focus slightly more on the latter
More informationDebapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata
SQL 4 Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata Slides re-used, with minor modification, from Silberschatz, Korth and Sudarshan www.db-book.com Outline Join Expressions Views
More informationCS3DB3/SE4DB3/SE6M03 TUTORIAL
CS3DB3/SE4DB3/SE6M03 TUTORIAL Mei Jiang Feb 13/15, 2013 Outline Relational Algebra SQL and Relational Algebra Examples Relational Algebra Basic Operators Select: C (R) where C is a list of conditions Project:
More informationFunctional dependency theory
Functional dependency theory Introduction to Database Design 2012, Lecture 8 Course evaluation Recalling normal forms Functional dependency theory Computing closures of attribute sets BCNF decomposition
More informationChapter 8: Relational Database Design
Chapter 8: Relational Database Design Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 8: Relational Database Design Features of Good Relational Design Atomic Domains
More informationNormalisation theory
Normalisation theory Introduction to Database Design 2012, Lecture 7 Challenging exercises E-R diagrams example Normalisation theory, motivation Functional dependencies Boyce-Codd normal form (BCNF) 3rd
More informationTriggers- View-Sequence
The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Database Lab (ECOM 4113) Lab 9 Triggers- View-Sequence Eng. Ibraheem Lubbad Triggers: A trigger is a PL/SQL block or
More informationDatabase Management Systems,
Database Management Systems Database Design (2) 1 Topics Data Base Design Logical Design (Review) Physical Design Entity Relationship (ER) Model to Relational Model Entity Relationship Attributes Normalization
More informationCS3DB3/SE4DB3/SE6M03 TUTORIAL
CS3DB3/SE4DB3/SE6M03 TUTORIAL Mei Jiang Jan 30/Feb 1, 013 Outline Connecting db server ANY, ALL, IN, EXISTS Operators Set Operations Connecting db server On Campus MacSecure Connect directly MacConnect
More informationChapter 2: Intro to Relational Model
Non è possibile visualizzare l'immagine. Chapter 2: Intro to Relational Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Example of a Relation attributes (or columns)
More informationUnit 3 : Relational Database Design
Unit 3 : Relational Database Design Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Content Relational Model: Basic concepts, Attributes and Domains, CODD's Rules, Relational
More informationASSIGNMENT NO 2. Objectives: To understand and demonstrate DDL statements on various SQL objects
ASSIGNMENT NO 2 Title: Design and Develop SQL DDL statements which demonstrate the use of SQL objects such as Table, View, Index, Sequence, Synonym Objectives: To understand and demonstrate DDL statements
More informationRelational Model. Nisa ul Hafidhoh
Relational Model Nisa ul Hafidhoh nisa@dsn.dinus.ac.id Data Model Collection of conceptual tools for describing data, data relationships, data semantics, and consistency constraints Example of Data Model
More informationDatabase Management Systems
Sample Questions 1 Write SQL query to create a table for describing a book. The table should have Book Title, Author, Publisher, Year published, and ISBN fields. Your table should have a primary key. For
More informationIntroduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)
Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Lecture 2 Lecture Overview 1. SQL introduction & schema definitions 2. Basic single-table queries
More informationCS143: 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 information7) To be considered a composite key, a key must contain at least two attributes. Answer: TRUE
Database Concepts, 7e (Kroenke/Auer) Chapter 2 The Relational Model 1) While the relational model for databases appears to hold much promise, few commercial databases have implemented it. Diff: 1 Page
More informationChapter 11: Indexing and Hashing
Chapter 11: Indexing and Hashing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files B-Tree
More informationRelational 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 informationIntroduction to Database Management Systems
Relational Data Model Relational Data Model 1 o Relations o Attributes o Tuples o Relations o Primary Keys o Objectives o Comparison to other models o Components o Relation Properties o Kinds of Relations
More informationChapter 7: Entity-Relationship Model. CS425 Fall 2016 Boris Glavic. Chapter 7: Entity-Relationship Model. Database Design.
Chapter 7: ntity-elationship Model Design Process CS425 Fall 2013 Boris Glavic Chapter 7: ntity-elationship Model Modeling Constraints - Diagram Design Issues Weak ntity Sets xtended - Features Design
More informationASSIGNMENT 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 informationCS425 Fall 2016 Boris Glavic Chapter 1: Introduction
CS425 Fall 2016 Boris Glavic Chapter 1: Introduction Modified from: Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Textbook: Chapter 1 1.2 Database Management System (DBMS)
More informationCS275 Intro to Databases
CS275 Intro to Databases The Relational Data Model Chap. 3 How Is Data Retrieved and Manipulated? Queries Data manipulation language (DML) Retrieval Add Delete Update An Example UNIVERSITY database Information
More information2.2.2.Relational Database concept
Foreign key:- is a field (or collection of fields) in one table that uniquely identifies a row of another table. In simpler words, the foreign key is defined in a second table, but it refers to the primary
More informationCMPT 354: Database System I. Lecture 2. Relational Model
CMPT 354: Database System I Lecture 2. Relational Model 1 Outline An overview of data models Basics of the Relational Model Define a relational schema in SQL 2 Outline An overview of data models Basics
More informationThe Extended Algebra. Duplicate Elimination. Sorting. Example: Duplicate Elimination
The Extended Algebra Duplicate Elimination 2 δ = eliminate duplicates from bags. τ = sort tuples. γ = grouping and aggregation. Outerjoin : avoids dangling tuples = tuples that do not join with anything.
More informationDatabase Technology Introduction. Heiko Paulheim
Database Technology Introduction Outline The Need for Databases Data Models Relational Databases Database Design Storage Manager Query Processing Transaction Manager Introduction to the Relational Model
More informationLecture 2: Introduction to SQL
Lecture 2: Introduction to SQL Lecture 2 Announcements! 1. If you still have Jupyter trouble, let us know! 2. Enroll to Piazza!!! 3. People are looking for groups. Team up! 4. Enrollment should be finalized
More informationCS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010
CS403- Database Management Systems Solved MCQS From Midterm Papers April 29,2012 MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01 CS403- Database Management Systems MIDTERM EXAMINATION - Spring
More informationDBMS. Relational Model. Module Title?
Relational Model Why Study the Relational Model? Most widely used model currently. DB2,, MySQL, Oracle, PostgreSQL, SQLServer, Note: some Legacy systems use older models e.g., IBM s IMS Object-oriented
More informationRelational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan
Relational Model DCS COMSATS Institute of Information Technology Rab Nawaz Jadoon Assistant Professor COMSATS IIT, Abbottabad Pakistan Management Information Systems (MIS) Relational Model Relational Data
More informationSQL Functions (Single-Row, Aggregate)
Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Database Lab (ECOM 4113) Lab 4 SQL Functions (Single-Row, Aggregate) Eng. Ibraheem Lubbad Part one: Single-Row Functions:
More informationLecture 1: Relational Databases
Lecture 1: Relational Databases CS1106/CS5021/CS6503 Introduction to Relational Databases Dr Kieran T. Herley Department of Computer Science University College Cork 2017-2018 KH (12/09/17) Lecture 1: Relational
More informationQUIZ: Buffer replacement policies
QUIZ: Buffer replacement policies Compute join of 2 relations r and s by nested loop: for each tuple tr of r do for each tuple ts of s do if the tuples tr and ts match do something that doesn t require
More informationQuery Processing & Optimization
Query Processing & Optimization 1 Roadmap of This Lecture Overview of query processing Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions Introduction
More informationDatabase 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