# 3. Relational Model and Relational Algebra

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 ECS-165A WQ Relational Model and Relational Algebra Contents Fundamental Concepts of the Relational Model Integrity Constraints Translation ER schema Relational Database Schema Relational Algebra Modification of the Database Overview Relational Model was introduced in 1970 by E.F. Codd (at IBM). Nice features: Simple and uniform data structures relations and solid theoretical foundation (important for query processing and optimization) Relational Model is basis for most DBMSs, e.g., Oracle, Microsoft SQL Server, IBM DB2, Sybase, PostgreSQL, MySQL,... Typically used in conceptual design: either directly (creating tables using SQL DDL) or derived from a given Entity- Relationship schema.

2 ECS-165A WQ Basic Structure of the Relational Model A relation r over collection of sets (domain values) D 1, D 2,..., D n is a subset of the Cartesian Product D 1 D 2... D n A relation thus is a set of n-tuples (d 1, d 2,..., d n ) where d i D i. Given the sets StudId = {412, 307, 540} StudName = {Smith, Jones} Major = {CS, CSE, BIO } then r = {(412, Smith, CS), (307, Jones, CSE), (412, Smith, CSE)} is a relation over StudId StudName Major Relation Schema, Database Schema, and Instances Let A 1, A 2,..., A n be attribute names with associated domains D 1, D 2,..., D n, then R(A 1 : D 1, A 2 : D 2,..., A n : D n ) is a relation schema. For example, Student(StudId : integer, StudName : string, Major : string) A relation schema specifies the name and the structure of the relation. A collection of relation schemas is called a relational database schema.

3 ECS-165A WQ Relation Schema, Database Schema, and Instances A relation instance r(r) of a relation schema can be thought of as a table with n columns and a number of rows. Instead of relation instance we often just say relation. An instance of a database schema thus is a collection of relations. An element t r(r) is called a tuple (or row). Student StudId StudName Major relation schema 412 Smith CS 307 Jones CSE tuple 412 Smith CSE A relation has the following properties: the order of rows is irrelevant, and there are no duplicate rows in a relation Integrity Constraints in the Relational Model Integrity constraints (ICs): must be true for any instance of a relation schema (admissible instances) ICs are specified when the schema is defined ICs are checked by the DBMS when relations (instances) are modified If DBMS checks ICs, then the data managed by the DBMS more closely correspond to the real-world scenario that is being modeled!

4 ECS-165A WQ Primary Key Constraints A set of attributes is a key for a relation if: 1. no two distinct tuples have the same values for all key attributes, and 2. this is not true for any subset of that key. If there is more than one key for a relation (i.e., we have a set of candidate keys), one is chosen (by the designer or DBA) to be the primary key. Student(StudId : number, StudName : string, Major : string) For candidate keys not chosen as primary key, uniqueness constraints can be specified. Note that it is often useful to introduce an artificial primary key (as a single attribute) for a relation, in particular if this relation is often referenced.

5 ECS-165A WQ Foreign Key Constraints and Referential Integrity Set of attributes in one relation (child relation) that is used to refer to a tuple in another relation (parent relation). Foreign key must refer to the primary key of the referenced relation. Foreign key attributes are required in relation schemas that have been derived from relationship types. Example: offers(prodname PRODUCTS, SName SUPPLIERS, Price) orders((fname, LName) CUSTOMERS, SName SUPPLIERS, Prodname PRODUCTS, Quantity) Foreign/primary key attributes must have matching domains. A foreign key constraint is satisfied for a tuple if either some values of the foreign key attributes are null (meaning a reference is not known), or the values of the foreign key attributes occur as the values of the primary key (of some tuple) in the parent relation. The combination of foreign key attributes in a relation schema typically builds the primary key of the relation, e.g., offers(prodname PRODUCTS, SName SUPPLIERS, Price) If all foreign key constraints are enforced for a relation, referential integrity is achieved, i.e., there are no dangling references.

6 ECS-165A WQ Translation of an ER Schema into a Relational Schema 1. Entity type E(A 1,..., A n, B 1,..., B m ) = relation schema E(A 1,..., A n, B 1,..., B m ). 2. Relationship type R(E 1,..., E n, A 1,..., A m ) with participating entity types E 1,..., E n ; X i foreign key attribute(s) referencing primary key attribute(s) of relation schema corresponding to E i. = R(X 1 E 1,..., X n E n, A 1,..., A m ) For a functional relationship (N:1, 1:N), an optimization is possible. Assume N:1 relationship type between E 1 and E 2. We can extend the schema of E 1 to E 1 (A 1,..., A n, X 2 E 2, B 1,..., B m ), e.g., EMPLOYEES(EmpId, DeptNo DEPARTMENTS,... )

7 ECS-165A WQ Example translation: DocId Title Publisher Year BOOKS describes borrows Date has written DESCRIPTIONS AUTHORS Keyword STUDENTS AName Address StId StName Major Year According to step 1: BOOKS(DocId, Title, Publisher, Year) STUDENTS(StId, StName, Major, Year) DESCRIPTIONS(Keyword) AUTHORS(AName, Address) In step 2 the relationship types are translated: borrows(docid BOOKS, StId STUDENTS, Date) has-written(docid BOOKS, AName AUTHORS) describes(docid BOOKS, Keyword DESCRIPTIONS) No need for extra relation for entity type DESCRIPTIONS : Descriptions(DocId BOOKS, Keyword)

8 ECS-165A WQ Query Languages 3.2 Relational Algebra A query language (QL) is a language that allows users to manipulate and retrieve data from a database. The relational model supports simple, powerful QLs (having strong formal foundation based on logics, allow for much optimization) Query Language!= Programming Language QLs are not expected to be Turing-complete, not intended to be used for complex applications/computations QLs support easy access to large data sets Categories of QLs: procedural versus declarative Two (mathematical) query languages form the basis for real languages (e.g., SQL) and for implementation Relational Algebra: procedural, very useful for representing query execution plans, and query optimization techniques. Relational Calculus: declarative, logic based language Understanding algebra (and calculus) is the key to understanding SQL, query processing and optimization.

9 ECS-165A WQ Relational Algebra Procedural language Queries in relational algebra are applied to relation instances, result of a query is again a relation instance Six basic operators in relational algebra: select σ selects a subset of tuples from reln project π deletes unwanted columns from reln Cartesian Product allows to combine two relations Set-difference tuples in reln. 1, but not in reln. 2 Union tuples in reln 1 plus tuples in reln 2 Rename ρ renames attribute(s) and relation The operators take one or two relations as input and give a new relation as a result (relational algebra is closed ).

10 ECS-165A WQ Select Operation Notation: σ P (r) Defined as σ P (r) := {t t r and P (t)} where r is a relation (name), P is a formula in propositional calculus, composed of conditions of the form <attribute> = <attribute> or <constant> Instead of = any other comparison predicate is allowed (, <, > etc). Conditions can be composed through (and), (or), (not) Example: given the relation r A B C D α α 1 7 α β 5 7 β β 12 3 β β σ A=B D>5 (r) A B C D α α 1 7 β β 23 10

11 ECS-165A WQ Project Operation Notation: π A1,A 2,...,A k (r) where A 1,..., A k are attribute names and r is a relation (name). The result of the projection operation is defined as the relation that has k columns obtained by erasing all columns from r that are not listed. Duplicate rows are removed from result because relations are sets. Example: given the relations r r A B C π A,C (r) A C α 10 2 α 20 2 β 30 2 β 40 4 α 2 β 2 β 4

12 ECS-165A WQ Cartesian Product Notation: r s where both r and s are relations Defined as r s := {tq t r and q s} Assume that attributes of r(r) and s(s) are disjoint, i.e., R S =. If attributes of r(r) and s(s) are not disjoint, then the rename operation must be applied first. Example: relations r, s: r A B s C D E α 1 β 2 α 10 + β 10 + β 20 γ 10 r s A B C D E α 1 α 10 + α 1 β 10 + α 1 β 20 α 1 γ 10 β 2 α 10 + β 2 β 10 + β 2 β 20 β 2 γ 10

13 ECS-165A WQ Union Operator Notation: r s where both r and s are relations Defined as r s := {t t r or t s} For r s to be applicable, 1. r, s must have the same number of attributes 2. Attribute domains must be compatible (e.g., 3rd column of r has a data type matching the data type of the 3rd column of s) Example: given the relations r and s r A B s A B α 1 α 2 β 1 α 2 β 3 r s A B α 1 α 2 β 1 β 3

14 ECS-165A WQ Set Difference Operator Notation: r s where both r and s are relations Defined as r s := {t t r and t s} For r s to be applicable, 1. r and s must have the same arity 2. Attribute domains must be compatible Example: given the relations r and s r A B s A B α 1 α 2 β 1 α 2 β 3 r s A B α 1 β 1

15 ECS-165A WQ Rename Operation Allows to name and therefore to refer to the result of relational algebra expression. Allows to refer to a relation by more than one name (e.g., if the same relation is used twice in a relational algebra expression). Example: ρ x (E) returns the relational algebra expression E under the name x If a relational algebra expression E (which is a relation) has the arity k, then ρ x(a1,a 2,...,A k )(E) returns the expression E under the name x, and with the attribute names A 1, A 2,..., A k.

16 ECS-165A WQ Composition of Operations It is possible to build relational algebra expressions using multiple operators similar to the use of arithmetic operators (nesting of operators) Example: σ A=C (r s) r s A B C D E α 1 α 10 + α 1 β 10 + α 1 β 20 α 1 γ 10 β 2 α 10 + β 2 β 10 + β 2 β 20 β 2 γ 10 σ A=C (r s) A B C D E α 1 α 10 + β 2 β 10 + β 2 β 20

17 ECS-165A WQ Example Queries Assume the following relations: BOOKS(DocId, Title, Publisher, Year) STUDENTS(StId, StName, Major, Age) AUTHORS(AName, Address) borrows(docid, StId, Date) has-written(docid, AName) describes(docid, Keyword) List the year and title of each book. π Year, Title (BOOKS) List all information about students whose major is CS. σ Major = CS (STUDENTS) List all students with the books they can borrow. STUDENTS BOOKS List all books published by McGraw-Hill before σ Publisher = McGraw-Hill Year<1990 (BOOKS)

18 ECS-165A WQ List the name of those authors who are living in Davis. π AName (σ Address like %Davis% (AUTHORS)) List the name of students who are older than 30 and who are not studying CS. π StName (σ Age>30 (STUDENTS)) π StName (σ Major= CS (STUDENTS)) Rename AName in the relation AUTHORS to Name. ρ AUTHORS(Name, Address) (AUTHORS)

19 ECS-165A WQ Composed Queries (formal definition) A basic expression in the relational algebra consists of either of the following: A relation in the database A constant relation (fixed set of tuples, e.g., {(1, 2), (1, 3), (2, 3)}) If E 1 and E 2 are expressions of the relational algebra, then the following expressions are relational algebra expressions, too: E 1 E 2 E 1 E 2 E 1 E 2 σ P (E 1 ) where P is a predicate on attributes in E 1 π A (E 1 ) where A is a list of some of the attributes in E 1 ρ x (E 1 ) where x is the new name for the result relation [and its attributes] determined by E 1

20 ECS-165A WQ Examples of Composed Queries 1. List the names of all students who have borrowed a book and who are CS majors. π StName (σ STUDENTS.StId=borrows.StId (σ Major= CS (STUDENTS) borrows)) 2. List the title of books written by the author Silberschatz. π Title (σ AName= Silberschatz (σ has-written.docid=books.docid (has-written BOOKS))) or π Title (σ has-written.docid=books.docid (σ AName= Silberschatz (has-written) BOOKS)) 3. As 2., but not books that have the keyword database.... as for π Title (σ describes.docid=books.docid (σ Keyword= database (describes) BOOKS)) 4. Find the name of the youngest student. π StName (STUDENTS) π S1.StName (σ S1.Age>S2.Age (ρ S1 (STUDENTS) ρ S2 (STUDENTS))) 5. Find the title of the oldest book. π Title (BOOKS) π B1.Title (σ B1.Year>B2.Year (ρ B1 (BOOKS) ρ B2 (BOOKS)))

21 ECS-165A WQ Additional Operators These operators do not add any power (expressiveness) to the relational algebra but simplify common (often complex and lengthy) queries. Set-Intersection Natural Join Condition Join C (also called Theta-Join) Division Assignment Set-Intersection Notation: r s Defined as r s := {t t r and t s} For r s to be applicable, 1. r and s must have the same arity 2. Attribute domains must be compatible Derivation: r s = r (r s) Example: given the relations r and s r A B α 1 α 2 β 1 s A B α 2 β 3 r s A B α 2

22 ECS-165A WQ Natural Join Notation: r s Let r, s be relations on schemas R and S, respectively. The result is a relation on schema R S. The result tuples are obtained by considering each pair of tuples t r r and t s s. If t r and t s have the same value for each of the attributes in R S ( same name attributes ), a tuple t is added to the result such that t has the same value as t r on r t has the same value as t s on s Example: Given the relations R(A, B, C, D) and S(B, D, E) Join can be applied because R S the result schema is (A, B, C, D, E) and the result of r s is defined as π r.a,r.b,r.c,r.d,s.e (σ r.b=s.b r.d=s.d (r s))

23 ECS-165A WQ Example: given the relations r and s r A B C D s B D E α 1 α a β 2 γ a γ 4 β b α 1 γ a δ 2 β b 1 a α 3 a β 1 a γ 2 b δ 3 b τ r s A B C D E α 1 α a α α 1 α a γ α 1 γ a α α 1 γ a γ δ 2 β b δ

24 ECS-165A WQ Condition Join Notation: r C s C is a condition on attributes in R S, result schema is the same as that of Cartesian Product. If R S and condition C refers to these attributes, some of these attributes must be renamed. Sometimes also called Theta Join (r θ s). Derivation: r C s = σ C (r s) Note that C is a condition on attributes from both r and s Example: given two relations r, s r A B C s D E r B<D s A B C D E

25 ECS-165A WQ If C involves only the comparison operator =, the condition join is also called Equi-Join. Example 2: r A B C s C D r C=SC (ρ S(SC,D) (s)) A B C SC D

26 ECS-165A WQ Division Notation: r s Precondition: attributes in S must be a subset of attributes in R, i.e., S R. Let r, s be relations on schemas R and S, respectively, where R(A 1,..., A m, B 1,..., B n ) S(B 1,..., B n ) The result of r s is a relation on schema R S = (A 1,..., A m ) Suited for queries that include the phrase for all. The result of the division operator consists of the set of tuples from r defined over the attributes R S that match the combination of every tuple in s. r s := {t t π R S (r) u s : tu r}

27 ECS-165A WQ Example: given the relations r, s: r A B C D E s D E α a α a 1 α a γ a 1 α a γ b 1 β a γ a 1 β a γ b 3 γ a γ a 1 γ a γ b 1 γ a β b 1 a 1 b 1 A B C r s α a γ γ a γ

28 ECS-165A WQ Assignment Operation ( ) that provides a convenient way to express complex queries. Idea: write query as sequential program consisting of a series of assignments followed by an expression whose value is displayed as the result of the query. Assignment must always be made to a temporary relation variable. The result to the right of is assigned to the relation variable on the left of the. This variable may be used in subsequent expressions. Example Queries 1. List each book with its keywords. BOOKS Descriptions Note that books having no keyword are not in the result. 2. List each student with the books s/he has borrowed. BOOKS (borrows STUDENTS)

29 ECS-165A WQ List the title of books written by the author Ullman. π Title (σ AName= Ullman (BOOKS has-written)) or π Title (BOOKS σ AName= Ullman (has-written)) 4. List the authors of the books the student Smith has borrowed. π AName (σ StName= Smith (has-written (borrows STUDENTS)) 5. Which books have both keywords database and programming? BOOKS (π DocId (σ Keyword= database (Descriptions )) π DocId (σ Keyword= programming (Descriptions))) or BOOKS (Descriptions {( database ), ( programming )}) with {( database ), ( programming )}) being a constant relation. 6. Query 4 using assignments. temp1 borrows STUDENTS temp2 has-written temp1 result π AName (σ StName= Smith (temp2))

30 ECS-165A WQ Modifications of the Database The content of the database may be modified using the operations insert, delete or update. Operations can be expressed using the assignment operator. r new operations on(r old ) Insert Either specify tuple(s) to be inserted, or write a query whose result is a set of tuples to be inserted. r r E, where r is a relation and E is a relational algebra expression. STUDENTS STUDENTS {(1024, Clark, CSE, 26)} Delete Analogous to insert, but operator instead of operator. Can only delete whole tuples, cannot delete values of particular attributes. STUDENTS STUDENTS (σ major= CS (STUDENTS)) Update Can be expressed as sequence of delete and insert operations. Delete operation deletes tuples with their old value(s) and insert operation inserts tuples with their new value(s).

### Introduction to Databases

Page 1 of 5 Introduction to Databases An introductory example What is a database? Why do we need Database Management Systems? The three levels of data abstraction What is a Database Management System?

### The Relational Model. Why Study the Relational Model?

The Relational Model Chapter 3 Instructor: Vladimir Zadorozhny vladimir@sis.pitt.edu Information Science Program School of Information Sciences, University of Pittsburgh 1 Why Study the Relational Model?

### CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

CS2Bh: Current Technologies Introduction to XML and Relational Databases Spring 2005 The Relational Model CS2 Spring 2005 (LN6) 1 The relational model Proposed by Codd in 1970. It is the dominant data

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

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

### Relational Algebra. Module 3, Lecture 1. Database Management Systems, R. Ramakrishnan 1

Relational Algebra Module 3, Lecture 1 Database Management Systems, R. Ramakrishnan 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model

### The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

The Relational Model Ramakrishnan&Gehrke, Chapter 3 CS4320 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. Legacy systems in older models

### IT2305 Database Systems I (Compulsory)

Database Systems I (Compulsory) INTRODUCTION This is one of the 4 modules designed for Semester 2 of Bachelor of Information Technology Degree program. CREDITS: 04 LEARNING OUTCOMES On completion of this

### Database Management Systems. Chapter 1

Database Management Systems Chapter 1 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 2 What Is a Database/DBMS? A very large, integrated collection of data. Models real-world scenarios

### IT2304: Database Systems 1 (DBS 1)

: Database Systems 1 (DBS 1) (Compulsory) 1. OUTLINE OF SYLLABUS Topic Minimum number of hours Introduction to DBMS 07 Relational Data Model 03 Data manipulation using Relational Algebra 06 Data manipulation

### Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

Outline Data Modeling Yanlei Diao UMass Amherst v Conceptual Design: ER Model v Relational Model v Logical Design: from ER to Relational Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 2 Conceptual

### www.gr8ambitionz.com

Data Base Management Systems (DBMS) Study Material (Objective Type questions with Answers) Shared by Akhil Arora Powered by www. your A to Z competitive exam guide Database Objective type questions Q.1

### Relational Algebra and SQL

Relational Algebra and SQL Johannes Gehrke johannes@cs.cornell.edu http://www.cs.cornell.edu/johannes Slides from Database Management Systems, 3 rd Edition, Ramakrishnan and Gehrke. Database Management

### The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

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

### 1 the relational data model The relational model of data was introduced by E.F. Codd (1970). 1.1 relational model concepts The relational model repres

database systems formal definitions of the relational data model [03] s. yurttaοs 1 1 the relational data model The relational model of data was introduced by E.F. Codd (1970). 1.1 relational model concepts

### EECS 647: Introduction to Database Systems

EECS 647: Introduction to Database Systems Instructor: Luke Huan Spring 2013 Administrative Take home background survey is due this coming Friday The grader of this course is Ms. Xiaoli Li and her email

### Lecture 6. SQL, Logical DB Design

Lecture 6 SQL, Logical DB Design Relational Query Languages A major strength of the relational model: supports simple, powerful querying of data. Queries can be written intuitively, and the DBMS is responsible

### Information Systems SQL. Nikolaj Popov

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

### 2. Conceptual Modeling using the Entity-Relationship Model

ECS-165A WQ 11 15 Contents 2. Conceptual Modeling using the Entity-Relationship Model Basic concepts: entities and entity types, attributes and keys, relationships and relationship types Entity-Relationship

### Fundamentals of Database Design

Fundamentals of Database Design Zornitsa Zaharieva CERN Data Management Section - Controls Group Accelerators and Beams Department /AB-CO-DM/ 23-FEB-2005 Contents : Introduction to Databases : Main Database

### Relational Databases

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

### 4. SQL. Contents. Example Database. CUSTOMERS(FName, LName, CAddress, Account) PRODUCTS(Prodname, Category) SUPPLIERS(SName, SAddress, Chain)

ECS-165A WQ 11 66 4. SQL Contents Basic Queries in SQL (select statement) Set Operations on Relations Nested Queries Null Values Aggregate Functions and Grouping Data Definition Language Constructs Insert,

### Basic Concepts of Database Systems

CS2501 Topic 1: Basic Concepts 1.1 Basic Concepts of Database Systems Example Uses of Database Systems - account maintenance & access in banking - lending library systems - airline reservation systems

### CS2Bh: Current Technologies. Introduction to XML and Relational Databases. Introduction to Databases. Why databases? Why not use XML?

CS2Bh: Current Technologies Introduction to XML and Relational Databases Spring 2005 Introduction to Databases CS2 Spring 2005 (LN5) 1 Why databases? Why not use XML? What is missing from XML: Consistency

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

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

### BCA. Database Management System

BCA IV Sem Database Management System Multiple choice questions 1. A Database Management System (DBMS) is A. Collection of interrelated data B. Collection of programs to access data C. Collection of data

### 1. INTRODUCTION TO RDBMS

Oracle For Beginners Page: 1 1. INTRODUCTION TO RDBMS What is DBMS? Data Models Relational database management system (RDBMS) Relational Algebra Structured query language (SQL) What Is DBMS? Data is one

### Database Systems. Lecture 1: Introduction

Database Systems Lecture 1: Introduction General Information Professor: Leonid Libkin Contact: libkin@ed.ac.uk Lectures: Tuesday, 11:10am 1 pm, AT LT4 Website: http://homepages.inf.ed.ac.uk/libkin/teach/dbs09/index.html

### In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

This Lecture Database Systems Lecture 5 Natasha Alechina The language, the relational model, and E/R diagrams CREATE TABLE Columns Primary Keys Foreign Keys For more information Connolly and Begg chapter

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

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

### ICAB4136B Use structured query language to create database structures and manipulate data

ICAB4136B Use structured query language to create database structures and manipulate data Release: 1 ICAB4136B Use structured query language to create database structures and manipulate data Modification

### 2. Basic Relational Data Model

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

### The Entity-Relationship Model

The Entity-Relationship Model 221 After completing this chapter, you should be able to explain the three phases of database design, Why are multiple phases useful? evaluate the significance of the Entity-Relationship

### ECS 165A: Introduction to Database Systems

ECS 165A: Introduction to Database Systems Todd J. Green based on material and slides by Michael Gertz and Bertram Ludäscher Winter 2011 Dept. of Computer Science UC Davis ECS-165A WQ 11 1 1. Introduction

### Database Implementation: SQL Data Definition Language

Database Systems Unit 5 Database Implementation: SQL Data Definition Language Learning Goals In this unit you will learn how to transfer a logical data model into a physical database, how to extend or

### Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB Outline Database concepts Conceptual Design Logical Design Communicating with the RDBMS 2 Some concepts Database: an

### The process of database development. Logical model: relational DBMS. Relation

The process of database development Reality (Universe of Discourse) Relational Databases and SQL Basic Concepts The 3rd normal form Structured Query Language (SQL) Conceptual model (e.g. Entity-Relationship

### Schema Mappings and Data Exchange

Schema Mappings and Data Exchange Phokion G. Kolaitis University of California, Santa Cruz & IBM Research-Almaden EASSLC 2012 Southwest University August 2012 1 Logic and Databases Extensive interaction

### Relational Database Basics Review

Relational Database Basics Review IT 4153 Advanced Database J.G. Zheng Spring 2012 Overview Database approach Database system Relational model Database development 2 File Processing Approaches Based on

### 8. Query Processing. Query Processing & Optimization

ECS-165A WQ 11 136 8. Query Processing Goals: Understand the basic concepts underlying the steps in query processing and optimization and estimating query processing cost; apply query optimization techniques;

### DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

DBMS Questions 1.) Which type of file is part of the Oracle database? A.) B.) C.) D.) Control file Password file Parameter files Archived log files 2.) Which statements are use to UNLOCK the user? A.)

### Chapter 5. SQL: Queries, Constraints, Triggers

Chapter 5 SQL: Queries, Constraints, Triggers 1 Overview: aspects of SQL DML: Data Management Language. Pose queries (Ch. 5) and insert, delete, modify rows (Ch. 3) DDL: Data Definition Language. Creation,

### SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7

SQL DATA DEFINITION: KEY CONSTRAINTS CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7 Data Definition 2 Covered most of SQL data manipulation operations Continue exploration of SQL

### Lesson 8: Introduction to Databases E-R Data Modeling

Lesson 8: Introduction to Databases E-R Data Modeling Contents Introduction to Databases Abstraction, Schemas, and Views Data Models Database Management System (DBMS) Components Entity Relationship Data

### Introduction to Microsoft Jet SQL

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

### Database Systems. Session 2 Main Theme. Relational Data. & Relational Database Constraints Dr. Jean-Claude Franchitti

Database Systems Session 2 Main Theme Relational Data Model & Relational Database Constraints Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical

### Course: CSC 222 Database Design and Management I (3 credits Compulsory)

Course: CSC 222 Database Design and Management I (3 credits Compulsory) Course Duration: Three hours per week for 15weeks with practical class (45 hours) As taught in 2010/2011 session Lecturer: Oladele,

### Unit 3. Retrieving Data from Multiple Tables

Unit 3. Retrieving Data from Multiple Tables What This Unit Is About How to retrieve columns from more than one table or view. What You Should Be Able to Do Retrieve data from more than one table or view.

### Instant SQL Programming

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

### SQL: Queries, Programming, Triggers

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

### There are five fields or columns, with names and types as shown above.

3 THE RELATIONAL MODEL Exercise 3.1 Define the following terms: relation schema, relational database schema, domain, attribute, attribute domain, relation instance, relation cardinality, andrelation degree.

### Lecture Slides 4. SQL Summary. presented by Timothy Heron. Indexes. Creating an index. Mathematical functions, for single values and groups of values.

CS252: Fundamentals of Relational Databases 1 CS252: Fundamentals of Relational Databases Lecture Slides 4 presented by Timothy Heron SQL Summary Mathematical functions, for single values and groups of

### Databases and BigData

Eduardo Cunha de Almeida eduardo.almeida@uni.lu Outline of the course Introduction Database Systems (E. Almeida) Distributed Hash Tables and P2P (C. Cassagnes) NewSQL (D. Kim and J. Meira) NoSQL (D. Kim)

### Oracle Database 10g: Introduction to SQL

Oracle University Contact Us: 1.800.529.0165 Oracle Database 10g: Introduction to SQL Duration: 5 Days What you will learn This course offers students an introduction to Oracle Database 10g database technology.

PART-I TYPICAL QUESTIONS & ANSWERS OBJECTIVE TYPE QUESTIONS Each question carries 2 marks. Choose the correct or best alternative in the following: Q.1 In the relational modes, cardinality is termed as:

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

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

### Relational Algebra. Basic Operations Algebra of Bags

Relational Algebra 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 --- symbols

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

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

### CSE 530A Database Management Systems. Introduction. Washington University Fall 2013

CSE 530A Database Management Systems Introduction Washington University Fall 2013 Overview Time: Mon/Wed 7:00-8:30 PM Location: Crow 206 Instructor: Michael Plezbert TA: Gene Lee Websites: http://classes.engineering.wustl.edu/cse530/

### Overview. Introduction to Database Systems. Motivation... Motivation: how do we store lots of data?

Introduction to Database Systems UVic C SC 370 Overview What is a DBMS? what is a relational DBMS? Why do we need them? How do we represent and store data in a DBMS? How does it support concurrent access

### SQL: Queries, Programming, Triggers

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

### Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations

1 Topics for this week: 1. Good Design 2. Functional Dependencies 3. Normalization Readings for this week: 1. E&N, Ch. 10.1-10.6; 12.2 2. Quickstart, Ch. 3 3. Complete the tutorial at http://sqlcourse2.com/

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

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

### Chapter 1: Introduction

Chapter 1: Introduction Database System Concepts, 5th Ed. See www.db book.com for conditions on re use Chapter 1: Introduction Purpose of Database Systems View of Data Database Languages Relational Databases

### LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24 1. A database schema is a. the state of the db b. a description of the db using a

### Θεµελίωση Βάσεων εδοµένων

Θεµελίωση Βάσεων εδοµένων Βασίλης Βασσάλος 1 What do we need to produce good software? Good programmers, software engineers, project managers, business experts, etc. (People) Good software development

### The core theory of relational databases. Bibliography

The core theory of relational databases Slide 1 La meilleure pratique... c est une bonne théorie Bibliography M.Levene, G.Loizou, Guided Tour of Relational Databases and Beyond, Springer, 625 pages,1999.

### SQL Simple Queries. Chapter 3.1 V3.0. Copyright @ Napier University Dr Gordon Russell

SQL Simple Queries Chapter 3.1 V3.0 Copyright @ Napier University Dr Gordon Russell Introduction SQL is the Structured Query Language It is used to interact with the DBMS SQL can Create Schemas in the

### SQL Server. 1. What is RDBMS?

SQL Server 1. What is RDBMS? Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained

### SQL : Structured Query Language data definition language

Outline SQL : Structured Query Language data definition language Introduction slide 150 slide 152 Integrity constraints slide 159 148 149 SQL presentation Introduction SQL Presentation (2) Introduction

### Chapter 1: Introduction. Database Management System (DBMS) University Database Example

This image cannot currently be displayed. Chapter 1: Introduction Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Database Management System (DBMS) DBMS contains information

### Ques 1. Define dbms and file management system? Ans- Database management system (DBMS) A file management system

UNIT-1 Ques 1. Define dbms and file management system? Ans- Database management system (DBMS) is a collection of interrelated data and a set of programs to access those data. Some of the very well known

### The Import & Export of Data from a Database

The Import & Export of Data from a Database Introduction The aim of these notes is to investigate a conceptually simple model for importing and exporting data into and out of an object-relational database,

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

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

### SQL Server. 2012 for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

TRAINING & REFERENCE murach's SQL Server 2012 for developers Bryan Syverson Joel Murach Mike Murach & Associates, Inc. 4340 N. Knoll Ave. Fresno, CA 93722 www.murach.com murachbooks@murach.com Expanded

### CSE 132A. Database Systems Principles

CSE 132A Database Systems Principles Prof. Victor Vianu 1 Data Management An evolving, expanding field: Classical stand-alone databases (Oracle, DB2, SQL Server) Computer science is becoming data-centric:

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

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

### Relational model. Relational model - practice. Relational Database Definitions 9/27/11. Relational model. Relational Database: Terminology

COS 597A: Principles of Database and Information Systems elational model elational model A formal (mathematical) model to represent objects (data/information), relationships between objects Constraints

### Logical Schema Design: The Relational Data Model

Logical Schema Design: The Relational Data Model Basics of the Relational Model From Conceptual to Logical Schema Logical Schema Design Select data model Hierarchical data model: hierarchies of record

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

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

### Review Entity-Relationship Diagrams and the Relational Model. Data Models. Review. Why Study the Relational Model? Steps in Database Design

Review Entity-Relationship Diagrams and the Relational Model CS 186, Fall 2007, Lecture 2 R & G, Chaps. 2&3 Why use a DBMS? OS provides RAM and disk A relationship, I think, is like a shark, you know?

### DBMS / Business Intelligence, SQL Server

DBMS / Business Intelligence, SQL Server Orsys, with 30 years of experience, is providing high quality, independant State of the Art seminars and hands-on courses corresponding to the needs of IT professionals.

### SQL, PL/SQL FALL Semester 2013

SQL, PL/SQL FALL Semester 2013 Rana Umer Aziz MSc.IT (London, UK) Contact No. 0335-919 7775 enquire@oeconsultant.co.uk EDUCATION CONSULTANT Contact No. 0335-919 7775, 0321-515 3403 www.oeconsultant.co.uk

### 1 File Processing Systems

COMP 378 Database Systems Notes for Chapter 1 of Database System Concepts Introduction A database management system (DBMS) is a collection of data and an integrated set of programs that access that data.

### Foundations of Information Management

Foundations of Information Management - WS 2012/13 - Juniorprofessor Alexander Markowetz Bonn Aachen International Center for Information Technology (B-IT) Data & Databases Data: Simple information Database:

### 6 CHAPTER. Relational Database Management Systems and SQL Chapter Objectives In this chapter you will learn the following:

6 CHAPTER Relational Database Management Systems and SQL Chapter Objectives In this chapter you will learn the following: The history of relational database systems and SQL How the three-level architecture

### CS143: Query and Update in SQL

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

### Exercise 1: Relational Model

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

### History of Database Systems

History of Database Systems By Kaushalya Dharmarathna(030087) Sandun Weerasinghe(040417) Early Manual System Before-1950s Data was stored as paper records. Lot of man power involved. Lot of time was wasted.

### Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

Database Design Overview Conceptual Design. The Entity-Relationship (ER) Model CS430/630 Lecture 12 Conceptual design The Entity-Relationship (ER) Model, UML High-level, close to human thinking Semantic

### Information Systems Analysis and Design CSC340. 2004 John Mylopoulos Database Design -- 2. Information Systems Analysis and Design CSC340

XX. Database Design Databases Databases and DBMS Data Models, Hierarchical, Network, Relational Database Design Restructuring an ER schema Performance analysis Analysis of Redundancies, Removing generalizations

### The Relational Data Model and Relational Database Constraints

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

### Introduction. Introduction: Database management system. Introduction: DBS concepts & architecture. Introduction: DBS versus File system

Introduction: management system Introduction s vs. files Basic concepts Brief history of databases Architectures & languages System User / Programmer Application program Software to process queries Software

### GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. COURSE CURRICULUM COURSE TITLE: DATABASE MANAGEMENT (Code: 3341605 ) Information Technology

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT COURSE CURRICULUM COURSE TITLE: DATABASE MANAGEMENT (Code: 3341605 ) Diploma Programme in which this course is offered Information Technology Semester

### Overview of Database Management Systems

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

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

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

### COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model The entity-relationship (E-R) model is a a data model in which information stored

### Databases. DSIC. Academic Year 2010-2011

Databases DSIC. Academic Year 2010-2011 1 Lecturer José Hernández-Orallo Office 236, 2nd floor DSIC. Email: jorallo@dsic.upv.es http://www.dsic.upv.es/~jorallo/docent/bda/bdaeng.html Attention hours On

### A Comparison of Database Query Languages: SQL, SPARQL, CQL, DMX

ISSN: 2393-8528 Contents lists available at www.ijicse.in International Journal of Innovative Computer Science & Engineering Volume 3 Issue 2; March-April-2016; Page No. 09-13 A Comparison of Database