ACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)

Size: px
Start display at page:

Download "ACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)"

Transcription

1 ACS-3902 Fall 2016 Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition) 1

2 The Relational Data Model and Relational Database Constraints Relational model Ted Codd (IBM) 1970 First commercial implementations available in early 1980s Widely used 2

3 Relational Model Concepts Database is a collection of relations Implementation of relation is a table comprising rows and columns In practice a table/relation represents an entity type or relationship type (entity-relationship model later) At intersection of a row and column in a table there is a simple value Row Represents a collection of related data values Formally called a tuple Column names Columns may be referred to as fields, or, formally as attributes Values in a column are drawn from a domain of values associated with the column/field/attribute 3

4 Relational Model Concepts 7 th edition Figure 5.1 4

5 Domain Atomic Domains A domain is a collection of values where each value is indivisible Not meaningful to decompose further Specifying a domain Name, data type, rules Examples domain of department codes for UW is a list: { ACS, MATH, ENGL, HIST, etc} domain of gender values for UW is the list ( male, female ) domain for credit hours is a value in the range [0,9] domain for salary is a Canadian dollar value >= $0 Cardinality: number of values in a domain Database implementation & support vary 5

6 Domain example - PostgreSQL CREATE DOMAIN us_postal_code AS TEXT CHECK( VALUE ~ '^\d{5}$' OR VALUE ~ '^\d{5}-\d{4}$' ); CREATE TABLE us_snail_addy ( address_id SERIAL PRIMARY KEY, street1 TEXT NOT NULL, street2 TEXT, street3 TEXT, city TEXT NOT NULL, postal us_postal_code NOT NULL ); 6

7 Domain example - PostgreSQL CREATE DOMAIN dom_payday AS date CONSTRAINT check_dow CHECK (trim(to_char(value, 'day')) = 'friday'); But now before April 1st 2011 our pay day was every Friday, but after April 1st 2011, pay day every Saturday. ALTER DOMAIN dom_payday DROP CONSTRAINT check_dow; ALTER DOMAIN dom_payday ADD CONSTRAINT check_dow CHECK ( (VALUE < ' '::date AND trim(to_char(value, 'day')) = 'friday') OR (VALUE >= ' '::date AND trim(to_char(value, 'day')) = 'saturday' ) ); 7

8 Relation schema R Relation Name R and has a listof attributes: Denoted by R (A 1, A 2,...,A n ) List of attributes A 1, A 2,..., A n Attribute A i Name of a role played by some domain D in the relation schema R Each attribute has a name and a domain Degree (or arity) of a relation Number of attributes (n) in its relation schema 8

9 Relations The relation (or relation state) r(r) Set of n-tuples r = {t 1, t 2,..., t m } Each n-tuple t Ordered list of n values t =<v 1, v 2,..., v n > m tuples in relation each tuple has n values each value comes from a domain Each value v i, 1 i n, is an element of domain A i or is NULL r(r) is a subset of the Cartesian product of the domains of R: r(r) (domain(a 1 ) domain (A 2 )... domain (A n )) 9

10 Relational Databases and Relational Database Schemas Relational database schema S Set of relation schemas S = {R 1, R 2,..., R m } Set of integrity constraints IC Relational database state Set of relation states DB = {r 1, r 2,..., r m } Each r i is a state of R i and such that the r i relation states satisfy integrity constraints specified in IC 10

11 Characteristics of Relations No ordering of tuples in a relation Relation defined as a set of tuples Order of attributes is not that important (some database systems may have some practical tips) 11

12 Characteristics of Relations (cont d.) Two ways of defining a tuple Definition 1 Each n-tuple is an ordered list of n values t =<v 1, v 2,..., v n > Definition 2 Each value v i, 1 i n, is an element of domain A i (or is a special NULL value) Each n-tuple is a set of (<attribute>, <value>) pairs Each pair gives the value of the mapping from an attribute A i to a value v i from dom(a i ) (or is a special NULL value) First definition of relation where attributes and the values within tuples are ordered leads to simpler notation 12

13 Characteristics of Relations (cont d.) Figures 5.1 and 5.2 show the same relation state order of tuples is not important 7 th edition Figure

14 Values Characteristics of Relations (cont d.) Each value in a tuple is atomic Flat relational model Composite and multivalued attributes not allowed First normal form assumption Multivalued attributes Must be represented by separate relations Composite attributes Represented only by simple component attributes in basic relational model Later we cover mapping ER and EER diagrams to relations 14

15 NULLs Characteristics of Relations (cont d.) Represent the values of attributes that may be unknown or may not apply to a tuple Meanings for NULL values Value unknown Value exists but is not available Attribute does not apply to this tuple (also known as value undefined) 15

16 Characteristics of Relations (cont d.) Interpretation (meaning) of a relation Each tuple in the relation is a fact In the Student relation there are five assertions : five students exist and have the characteristics given We must be able to make statements regarding the meaning of tuples. E.g. Dick Davidson is identified by the SSN , has an unknown home phone number, lives at 3452 Elgin Road, has an office phone number (817) , is of age 25 and has a current gpa of

17 Relational Model Notation To refer to the current set of tuples (its state): STUDENT To refer to the schema: STUDENT ( Name, Ssn, Home_phone, Address, Office_phone, Age, Gpa) An attribute can be qualified with the relation name to which it belongs by using dot notation: STUDENT.Name 17

18 Constraints Constraints Restrictions on the actual values in a database state Derived from the rules in the miniworld that the database represents Three categories: Constraints inherent in the data model Constraints expressed in the schema General constraints not falling into the first two categories Expressed in application code 18

19 Constraints Constraints expressed in a data model: there are no duplicate tuples There is at least one attribute value that differentiates one student from another Values for an attribute must come from its domain Each Ssn value is numeric and properly formatted However, in practice these are expressed in the DDL 19

20 Relational Model Constraints (cont d.) Schema-based constraints Domains Keys NULLs Entity integrity Referential integrity 20

21 Domain Constraints In DDL we specify a datatype for an attribute Numeric data types for integers and real numbers Characters Booleans etc. CREATE TABLE Customer( First_Name char(50), Last_Name char(50), Address char(50), City char(50), Country char(25), Birth_Date datetime ); 21

22 Domain Constraints In DDL we can specify a check constraint for an attribute E.g. suppose the value of the age attribute in row must be greater than zero. The following will cause INSERT Customer( joe, smith,0) to be rejected CREATE TABLE Customer( First_Name char(50), Last_Name char(50), Age int check (age >0) ); 22

23 Domain Constraints In DDL we can ensure each row has a value for an attribute E.g. suppose the value of the age attribute in row must be known. The following will cause INSERT Customer( joe, smith,null) to be rejected CREATE TABLE Customer( First_Name char(50), Last_Name char(50), Age int NOT NULL ); 23

24 Domain Constraints SQL has a create domain statement (see page 94). Examples: CREATE DOMAIN persons_name CHAR(30) ; CREATE DOMAIN street_address CHAR(35) ; domain definitions can be used in DDL: CREATE TABLE Customers ( ID INT DEFAULT AUTOINCREMENT PRIMARY KEY, Name persons_name, Street street_address); 24

25 Key Constraints No two tuples can have the same combination of values for all their attributes. Superkey: combination of attributes such that every tuple will have a unique value Key Of course, a key is a superkey But a key is minimal in the sense that if you remove an attribute from the key it is no longer a superkey 25

26 Key Constraints Candidate key Relation schema may have more than one key SQL: unique constraint Primary key of the relation Only one CK is designated as the PK Other candidate keys are designated as unique keys ( secondary keys or alternate keys) SQL: primary key clause 26

27 Key Constraints CREATE TABLE Schedule ( eventid INT, room CHAR(10), starttime DATETIME, endtime DATETIME, eventdescription VARCHAR(255), CONSTRAINT pk PRIMARY KEY (eventid), CONSTRAINT ck1 UNIQUE (room, starttime), CONSTRAINT ck2 UNIQUE (room, endtime), ); 27

28 Referential Integrity Constraints Empid Mgrid Empname Salary 1 NULL Nancy Andrew Janet Margaret Steven Michael Robert Laura Ann Ina David Ron Dan James Mgrid must be null or have a value that exists in a row of Employee 28

29 Referential Integrity Constraints Mgrid must be null or have a value that exists in a row of Employee CREATE TABLE Employees ( empid int NOT NULL, mgrid int NULL, empname varchar(25) NOT NULL, salary money NOT NULL, CONSTRAINT PK_Employees_empid PRIMARY KEY(empid), CONSTRAINT FK_Employees_Employees FOREIGN KEY(mgrid) REFERENCES Employees(empid) ) ; 29

30 PK PK composite PK 30

31 5.7 FK references a PK 31

32 Foreign key rules: Referential Integrity The attributes in FK have the same domain(s) as the primary key attributes PK Value of FK in a tuple t 1 of the current state r 1 (R 1 ) either occurs as a value of PK for some tuple t 2 in the current state r 2 (R 2 ) or is NULL 32

33 Semantic integrity constraints Other Types of Constraints The UoD may require constraints that cannot be expressed in DDL Can use: Application code Triggers (section 5.2) Section 7.2 Section 10.2 Automatically executed on an event such as an insert Stored procedures (section Section ) Procedure stored in the db engine Assertions (section Section 5.2) 7.2 An sql statement that specified a condition (like a SQL Select) that must be true at all times 33

34 Database Operations Operations of the relational model can be categorized into retrievals and updates Basic operations that change the states of relations in the database: Insert Delete Update (or Modify) 34

35 Transaction Transactions An executing program includes database operations surrounded by Begin, Commit, Rollback Unit of work ACID properties (see ACS-4902) Example using pseuodocode: Begin transaction Update account set balance = balance 100 where accno = 1 Update account set balance = balance where accno = 2 If no errors then Commit the transaction Otherwise Rollback the transaction More on transactions ACS

36 Transactions in PostgreSQL BEGIN; UPDATE accounts SET balance = balance WHERE name = 'Alice'; UPDATE accounts SET balance = balance WHERE name = 'Wally '; COMMIT; 36

37 Transactions in PostgreSQL BEGIN; UPDATE accounts SET balance = balance WHERE name = 'Alice'; SAVEPOINT my_savepoint; UPDATE accounts SET balance = balance WHERE name = 'Bob'; Nested transaction -- oops... forget that and use Wally's account ROLLBACK TO my_savepoint; UPDATE accounts SET balance = balance WHERE name = 'Wally'; COMMIT; 37

38 Transactions in MySQL START TRANSACTION; UPDATE accounts SET balance = balance WHERE name = 'Alice'; SAVEPOINT my_savepoint; UPDATE accounts SET balance = balance WHERE name = 'Bob'; Nested transaction -- oops... forget that and use Wally's account ROLLBACK TO my_savepoint; UPDATE accounts SET balance = balance WHERE name = 'Wally'; COMMIT; 38

The Basic (Flat) Relational Model. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

The Basic (Flat) Relational Model. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley The Basic (Flat) Relational Model Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 Outline The Relational Data Model and Relational Database Constraints Relational

More information

ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION

ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION JING YANG 2010 FALL Class 3: The Relational Data Model and Relational Database Constraints Outline 2 The Relational Data Model and Relational Database Constraints

More information

CS275 Intro to Databases

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

CS 377 Database Systems

CS 377 Database Systems CS 377 Database Systems Relational Data Model Li Xiong Department of Mathematics and Computer Science Emory University 1 Outline Relational Model Concepts Relational Model Constraints Relational Database

More information

ECE 650 Systems Programming & Engineering. Spring 2018

ECE 650 Systems Programming & Engineering. Spring 2018 ECE 650 Systems Programming & Engineering Spring 2018 Relational Databases: Tuples, Tables, Schemas, Relational Algebra Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) Overview

More information

COSC344 Database Theory and Applications. σ a= c (P) Lecture 3 The Relational Data. Model. π A, COSC344 Lecture 3 1

COSC344 Database Theory and Applications. σ a= c (P) Lecture 3 The Relational Data. Model. π A, COSC344 Lecture 3 1 COSC344 Database Theory and Applications σ a= c (P) S P Lecture 3 The Relational Data π A, C (H) Model COSC344 Lecture 3 1 Overview Last Lecture Database design ER modelling This Lecture Relational model

More information

Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra

Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra Relational Data Model and Relational Constraints Part 1 A simplified diagram to illustrate the main

More information

Relational Data Model. Christopher Simpkins

Relational Data Model. Christopher Simpkins Relational Data Model Christopher Simpkins 1 / 22 Relational Data Model A relation schema R(A a,..., A n ) is a relation name R and a list of attributes A 1,..., A n. Each attribute A i is the name of

More information

01/01/2017. Chapter 5: The Relational Data Model and Relational Database Constraints: Outline. Chapter 5: Relational Database Constraints

01/01/2017. Chapter 5: The Relational Data Model and Relational Database Constraints: Outline. Chapter 5: Relational Database Constraints Chapter 5: The Relational Data Model and Relational Database Constraints: Outline Ramez Elmasri, Shamkant B. Navathe(2017) Fundamentals of Database Systems (7th Edition),pearson, isbn 10: 0-13-397077-9;isbn-13:978-0-13-397077-7.

More information

Relational Database Systems Part 01. Karine Reis Ferreira

Relational Database Systems Part 01. Karine Reis Ferreira Relational Database Systems Part 01 Karine Reis Ferreira karine@dpi.inpe.br Aula da disciplina Computação Aplicada I (CAP 241) 2016 Database System Database: is a collection of related data. represents

More information

The Relational Data Model and Relational Database Constraints

The Relational Data Model and Relational Database Constraints CHAPTER 5 The Relational Data Model and Relational Database Constraints Copyright 2017 Ramez Elmasri and Shamkant B. Navathe Slide 1-2 Chapter Outline Relational Model Concepts Relational Model Constraints

More information

The Relational Model

The Relational Model The Relational Model What is the Relational Model Relations Domain Constraints SQL Integrity Constraints Translating an ER diagram to the Relational Model and SQL Views A relational database consists

More information

Chapter 6: RELATIONAL DATA MODEL AND RELATIONAL ALGEBRA

Chapter 6: RELATIONAL DATA MODEL AND RELATIONAL ALGEBRA Chapter 6: Relational Data Model and Relational Algebra 1 Chapter 6: RELATIONAL DATA MODEL AND RELATIONAL ALGEBRA RELATIONAL MODEL CONCEPTS The relational model represents the database as a collection

More information

Relational Model. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

Relational Model. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011 Relational Model IT 5101 Introduction to Database Systems J.G. Zheng Fall 2011 Overview What is the relational model? What are the most important practical elements of the relational model? 2 Introduction

More information

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul 1 EGCI 321: Database Systems Dr. Tanasanee Phienthrakul 2 Chapter 10 Data Definition Language (DDL) 3 Basic SQL SQL language Considered one of the major reasons for the commercial success of relational

More information

THE RELATIONAL DATA MODEL CHAPTER 3 (6/E) CHAPTER 5 (5/E)

THE RELATIONAL DATA MODEL CHAPTER 3 (6/E) CHAPTER 5 (5/E) 1 THE RELATIONAL DATA MODEL CHAPTER 3 (6/E) CHAPTER 5 (5/E) 2 LECTURE OUTLINE Relational Model Concepts Relational Database Schemas Update Operations Brief History of Database Applications (from Section

More information

CSC 742 Database Management Systems

CSC 742 Database Management Systems CSC 742 Database Management Systems Topic #5: Relational Model Spring 2002 CSC 742: DBMS by Dr. Peng Ning 1 Motivation A relation is a mathematical abstraction for a table The theory of relations provides

More information

CSIT5300: Advanced Database Systems

CSIT5300: Advanced Database Systems CSIT5300: Advanced Database Systems L02: Relational Data Model Dr. Kenneth LEUNG Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong SAR, China kwtleung@cse.ust.hk

More information

The Relational Data Model and Relational Database Constraints

The Relational Data Model and Relational Database Constraints The Relational Data Model and Relational Database Constraints First introduced by Ted Codd from IBM Research in 1970, seminal paper, which introduced the Relational Model of Data representation. It is

More information

DATABASE TECHNOLOGY - 1DL124

DATABASE TECHNOLOGY - 1DL124 1 DATABASE TECHNOLOGY - 1DL124 Summer 2007 An introductury course on database systems http://user.it.uu.se/~udbl/dbt-sommar07/ alt. http://www.it.uu.se/edu/course/homepage/dbdesign/st07/ Kjell Orsborn

More information

PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore ) Department of MCA. Solution Set - Test-II

PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore ) Department of MCA. Solution Set - Test-II PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore 560100 ) Solution Set - Test-II Sub: Database Management Systems 16MCA23 Date: 04/04/2017 Sem & Section:II Duration:

More information

CONSTRAINTS AND UPDATES CHAPTER 3 (6/E) CHAPTER 5 (5/E)

CONSTRAINTS AND UPDATES CHAPTER 3 (6/E) CHAPTER 5 (5/E) 1 CONSTRAINTS AND UPDATES CHAPTER 3 (6/E) CHAPTER 5 (5/E) 3 LECTURE OUTLINE Constraints in Relational Databases Update Operations 4 SATISFYING INTEGRITY CONSTRAINTS Constraints are restrictions on the

More information

Data Modeling with the Entity Relationship Model. CS157A Chris Pollett Sept. 7, 2005.

Data Modeling with the Entity Relationship Model. CS157A Chris Pollett Sept. 7, 2005. Data Modeling with the Entity Relationship Model CS157A Chris Pollett Sept. 7, 2005. Outline Conceptual Data Models and Database Design An Example Application Entity Types, Sets, Attributes and Keys Relationship

More information

DBMS. Relational Model. Module Title?

DBMS. 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 information

Chapter 4. The Relational Model

Chapter 4. The Relational Model Chapter 4 The Relational Model Chapter 4 - Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations and relations in the relational model.

More information

The Relational Model

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

More information

Database Technology Introduction. Heiko Paulheim

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

DATABASE DESIGN I - 1DL300

DATABASE DESIGN I - 1DL300 DATABASE DESIGN I - 1DL300 Spring 2011 An introductory course on database systems http://www.it.uu.se/edu/course/homepage/dbastekn/vt11/ Manivasakan Sabesan Uppsala Database Laboratory Department of Information

More information

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

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

More information

The Relational Model. Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC)

The Relational Model. Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) The Relational Model Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) Why Study the Relational Model? Most widely used model in Commercial DBMSs: Vendors: IBM, Microsoft,

More information

Relational Model and Relational Algebra

Relational Model and Relational Algebra UNIT-III Relational Model and Relational Algebra 1) Define the following terms with an example for each. 8 Marks (Jun / July2014) Super key: A set of attributes SK of R such that no two tuples in any valid

More information

The Relational Data Model (ALL the Vocabulary)

The Relational Data Model (ALL the Vocabulary) (ALL the Vocabulary) Lecture 2 1 A Quick Reminder One of the key features of a DBMS is use of data models to support data independence The conceptual representation is independent of underlying storage

More information

Chapter 5. The Relational Data Model and Relational Database Constraints. Slide 5-١. Copyright 2007 Ramez Elmasri and Shamkant B.

Chapter 5. The Relational Data Model and Relational Database Constraints. Slide 5-١. Copyright 2007 Ramez Elmasri and Shamkant B. Slide 5-١ Chapter 5 The Relational Data Model and Relational Database Constraints Chapter Outline Relational Model Concepts Relational Model Constraints and Relational Database Schemas Update Operations

More information

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 5-1

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 5-1 Slide 5-1 Chapter 5 The Relational Data Model and Relational Database Constraints Chapter Outline Relational Model Concepts Relational Model Constraints and Relational Database Schemas Update Operations

More information

The data structures of the relational model Attributes and domains Relation schemas and database schemas

The data structures of the relational model Attributes and domains Relation schemas and database schemas The data structures of the relational model Attributes and domains Relation schemas and database schemas databases First normal form (1NF) Running Example Pubs-Drinkers-DB: Pubs (name, location) Drinkers

More information

Let s briefly review important EER inheritance concepts

Let s briefly review important EER inheritance concepts Let s briefly review important EER inheritance concepts 1 is-a relationship Copyright (c) 2011 Pearson Education 2 Basic Constraints Partial / Disjoint: Single line / d in circle Each entity can be an

More information

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data. Managing Data Data storage tool must provide the following features: Data definition (data structuring) Data entry (to add new data) Data editing (to change existing data) Querying (a means of extracting

More information

DATABASE TECHNOLOGY. Spring An introduction to database systems

DATABASE TECHNOLOGY. Spring An introduction to database systems 1 DATABASE TECHNOLOGY Spring 2007 An introduction to database systems Kjell Orsborn Uppsala Database Laboratory Department of Information Technology, Uppsala University, Uppsala, Sweden 2 Introduction

More information

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530 Translation of ER-diagram into Relational Schema Dr. Sunnie S. Chung CIS430/530 Learning Objectives Define each of the following database terms 9.2 Relation Primary key Foreign key Referential integrity

More information

Structured Query Language (SQL)

Structured Query Language (SQL) Structured Query Language (SQL) SQL Chapters 6 & 7 (7 th edition) Chapters 4 & 5 (6 th edition) PostgreSQL on acsmysql1.acs.uwinnipeg.ca Each student has a userid and initial password acs!

More information

Introduction to Databases

Introduction to Databases Introduction to Databases Abou Bakar Kaleem 1 Overview - Database - Relational Databases - Introduction to SQL Introduction to Databases 2 1 Database (1) Database : - is a collection of related data -

More information

L12: ER modeling 5. CS3200 Database design (sp18 s2) 2/22/2018

L12: ER modeling 5. CS3200 Database design (sp18 s2)   2/22/2018 L12: ER modeling 5 CS3200 Database design (sp18 s2) https://course.ccs.neu.edu/cs3200sp18s2/ 2/22/2018 200 Announcements! Keep bringing your name plates J Exam 1 discussion: questions on grading: Piazza,

More information

CMPT 354: Database System I. Lecture 2. Relational Model

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

Chapter 5. Relational Model Concepts 9/4/2012. Chapter Outline. The Relational Data Model and Relational Database Constraints

Chapter 5. Relational Model Concepts 9/4/2012. Chapter Outline. The Relational Data Model and Relational Database Constraints Chapter 5 The Relational Data Model and Relational Database Constraints Copyright 2004 Pearson Education, Inc. Chapter Outline Relational Model Constraints and Relational Database Schemas Update Operations

More information

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530 Translation of ER-diagram into Relational Schema Dr. Sunnie S. Chung CIS430/530 Learning Objectives Define each of the following database terms Relation Primary key Foreign key Referential integrity Field

More information

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

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

More information

Ch 9: Mapping EER to Relational. Follow a seven-step algorithm to convert the basic ER model constructs into relations steps 1-7

Ch 9: Mapping EER to Relational. Follow a seven-step algorithm to convert the basic ER model constructs into relations steps 1-7 Ch 9: Mapping EER to Relational Follow a seven-step algorithm to convert the basic ER model constructs into relations steps 1-7 Additional steps for EER model for specialization/generalization steps 8a

More information

Data about data is database Select correct option: True False Partially True None of the Above

Data about data is database Select correct option: True False Partially True None of the Above Within a table, each primary key value. is a minimal super key is always the first field in each table must be numeric must be unique Foreign Key is A field in a table that matches a key field in another

More information

A database can be modeled as: + a collection of entities, + a set of relationships among entities.

A database can be modeled as: + a collection of entities, + a set of relationships among entities. The Relational Model Lecture 2 The Entity-Relationship Model and its Translation to the Relational Model Entity-Relationship (ER) Model + Entity Sets + Relationship Sets + Database Design Issues + Mapping

More information

CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model

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

CSE 132A Database Systems Principles

CSE 132A Database Systems Principles CSE 132A Database Systems Principles Prof. Alin Deutsch RELATIONAL DATA MODEL Some slides are based or modified from originals by Elmasri and Navathe, Fundamentals of Database Systems, 4th Edition 2004

More information

Running Example Tables name location

Running Example Tables name location Running Example Pubs-Drinkers-DB: The data structures of the relational model Attributes and domains Relation schemas and database schemas databases Pubs (name, location) Drinkers (name, location) Sells

More information

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall The Relational Model Chapter 3 Comp 521 Files and Databases Fall 2012 1 Why Study the Relational Model? Most widely used model by industry. IBM, Informix, Microsoft, Oracle, Sybase, etc. It is simple,

More information

CS530 Database Architecture Models. Database Model. Prof. Ian HORROCKS. Dr. Robert STEVENS. and Design The Relational

CS530 Database Architecture Models. Database Model. Prof. Ian HORROCKS. Dr. Robert STEVENS. and Design The Relational 02 - The Relational Database Model CS530 Database Architecture Models and Design Prof. Ian HORROCKS Dr. Robert STEVENS In this Section Topics Covered The basics of the relational model in the context of

More information

Chapter 5. Relational Model Concepts 5/2/2008. Chapter Outline. Relational Database Constraints

Chapter 5. Relational Model Concepts 5/2/2008. Chapter Outline. Relational Database Constraints Chapter 5 The Relational Data Model and Relational Database Constraints Copyright 2004 Pearson Education, Inc. Chapter Outline Relational Model Concepts Relational Model Constraints and Relational Database

More information

Relational Model. Topics. Relational Model. Why Study the Relational Model? Linda Wu (CMPT )

Relational Model. Topics. Relational Model. Why Study the Relational Model? Linda Wu (CMPT ) Topics Relational Model Linda Wu Relational model SQL language Integrity constraints ER to relational Views (CMPT 354 2004-2) Chapter 3 CMPT 354 2004-2 2 Why Study the Relational Model? Most widely used

More information

The Relational Model of Data (ii)

The Relational Model of Data (ii) ICS 321 Fall 2013 The Relational Model of Data (ii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1 Defining Relational Schema in SQL Two aspects: Data

More information

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

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

More information

Comp 5311 Database Management Systems. 2. Relational Model and Algebra

Comp 5311 Database Management Systems. 2. Relational Model and Algebra Comp 5311 Database Management Systems 2. Relational Model and Algebra 1 Basic Concepts of the Relational Model Entities and relationships of the E-R model are stored in tables also called relations (not

More information

A database consists of several tables (relations) AccountNum

A database consists of several tables (relations) AccountNum rela%onal model Relational Model A database consists of several tables (relations) Customer Account Depositor CustID Name Street City State AccountNum Balance CustID AccountNum Columns in the tables are

More information

Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5-1

Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5-1 Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5-1 Chapter 5 The Relational Data Model and Relational Database Constraints Copyright 2007 Pearson Education, Inc. Publishing

More information

Relational Model. Courses B0B36DBS, A4B33DS, A7B36DBS: Database Systems. Lecture 02: Martin Svoboda

Relational Model. Courses B0B36DBS, A4B33DS, A7B36DBS: Database Systems. Lecture 02: Martin Svoboda Courses B0B36DBS, A4B33DS, A7B36DBS: Database Systems Lecture 02: Relational Model Martin Svoboda 28. 2. 2017 Faculty of Electrical Engineering, Czech Technical University in Prague Lecture Outline Logical

More information

The Relational Model

The Relational Model The Relational Model UVic C SC 370, Fall 2002 Daniel M. German Department of Computer Science University of Victoria September 25, 2002 Version: 1.03 3 1 The Relational Model (1.03) CSC 370 dmgerman@uvic.ca

More information

Data Modeling. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

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

More information

DC62 Database management system JUNE 2013

DC62 Database management system JUNE 2013 Q2 (a) Explain the differences between conceptual & external schema. Ans2 a. Page Number 24 of textbook. Q2 (b) Describe the four components of a database system. A database system is composed of four

More information

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

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

More information

The Relational Model. Week 2

The Relational Model. Week 2 The Relational Model Week 2 1 Relations A relation is a more concrete construction, of something we have seen before, the ER diagram. name S.S.N students street city A relation is (just!) a table! We will

More information

The Relational Model Constraints and SQL DDL

The Relational Model Constraints and SQL DDL The Relational Model Constraints and SQL DDL Week 2-3 Weeks 2-3 MIE253-Consens 1 Schedule Week Date Lecture Topic 1 Jan 9 Introduction to Data Management 2 Jan 16 The Relational Model 3 Jan. 23 Constraints

More information

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall The Relational Model Chapter 3 Comp 521 Files and Databases Fall 2014 1 Why the Relational Model? Most widely used model by industry. IBM, Informix, Microsoft, Oracle, Sybase, MySQL, Postgres, Sqlite,

More information

Database Technology. Topic 2: Relational Databases and SQL. Olaf Hartig.

Database Technology. Topic 2: Relational Databases and SQL. Olaf Hartig. Topic 2: Relational Databases and SQL Olaf Hartig olaf.hartig@liu.se Relational Data Model Recall: DB Design Process 3 Relational Model Concepts Relational database: represent data as a collection of relations

More information

Database Applications (15-415)

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

More information

The Relational Model. Roadmap. Relational Database: Definitions. Why Study the Relational Model? Relational database: a set of relations

The Relational Model. Roadmap. Relational Database: Definitions. Why Study the Relational Model? Relational database: a set of relations The Relational Model CMU SCS 15-415/615 C. Faloutsos A. Pavlo Lecture #3 R & G, Chap. 3 Roadmap Introduction Integrity constraints (IC) Enforcing IC Querying Relational Data ER to tables Intro to Views

More information

Chapter 1: Introduction

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

The Relational Model. CS157A Chris Pollett Sept. 19, 2005.

The Relational Model. CS157A Chris Pollett Sept. 19, 2005. The Relational Model CS157A Chris Pollett Sept. 19, 2005. Outline A little bit on Oracle on sigma Introduction to the Relational Model Oracle on Sigma Two ways to connect: connect to sigma, then connect

More information

The Relational Model. Outline. Why Study the Relational Model? Faloutsos SCS object-relational model

The Relational Model. Outline. Why Study the Relational Model? Faloutsos SCS object-relational model The Relational Model CMU SCS 15-415 C. Faloutsos Lecture #3 R & G, Chap. 3 Outline Introduction Integrity constraints (IC) Enforcing IC Querying Relational Data ER to tables Intro to Views Destroying/altering

More information

Introduction to Data Management. Lecture #5 Relational Model (Cont.) & E-Rà Relational Mapping

Introduction to Data Management. Lecture #5 Relational Model (Cont.) & E-Rà Relational Mapping Introduction to Data Management Lecture #5 Relational Model (Cont.) & E-Rà Relational Mapping Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1

More information

Database Logical Design

Database Logical Design Database Logical Design IT 5101 Introduction to Database Systems J.G. Zheng Fall 2011 Overview Relational model is a logical model Based on mathematical theories and rules Two ways to design a relational

More information

Keys are fields in a table which participate in below activities in RDBMS systems:

Keys are fields in a table which participate in below activities in RDBMS systems: Keys are fields in a table which participate in below activities in RDBMS systems: 1. To create relationships between two tables. 2. To maintain uniqueness in a table. 3. To keep consistent and valid data

More information

Relational Data Model

Relational Data Model Relational Data Model 1. Relational data model Information models try to put the real-world information complexity in a framework that can be easily understood. Data models must capture data structure

More information

The Relational Model. Chapter 3

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

More information

DATABASE TECHNOLOGY - 1MB025 (also 1DL029, 1DL300+1DL400)

DATABASE TECHNOLOGY - 1MB025 (also 1DL029, 1DL300+1DL400) 1 DATABASE TECHNOLOGY - 1MB025 (also 1DL029, 1DL300+1DL400) Spring 2008 An introductury course on database systems http://user.it.uu.se/~udbl/dbt-vt2008/ alt. http://www.it.uu.se/edu/course/homepage/dbastekn/vt08/

More information

CS 2451 Database Systems: Relational Data Model

CS 2451 Database Systems: Relational Data Model CS 2451 Database Systems: Relational Data Model http://www.seas.gwu.edu/~bhagiweb/cs2541 Spring 2018 Instructor: Dr. Bhagi Narahari Lead TA: Roxana Leontie TA/Grader: Malik Undergrad TA: Victoria Zheng

More information

In mathematical terms, the relation itself can be expressed simply in terms of the attributes it contains:

In mathematical terms, the relation itself can be expressed simply in terms of the attributes it contains: The Relational Model The relational data model organises data as 2-dimensional tables or relations. An example of one such relation would be STUDENT shown below. As we have seen in the wine list example,

More information

CONSTRAINTS AND UPDATES CHAPTER 3 (6/E) CHAPTER 5 (5/E)

CONSTRAINTS AND UPDATES CHAPTER 3 (6/E) CHAPTER 5 (5/E) 1 CONSTRAINTS AND UPDATES CHAPTER 3 (6/E) CHAPTER 5 (5/E) QUESTION Film title genre year director runtime budget gross The Company Men drama 2010 John Wells 104 15,000,000 4,439,063 Steven Lincoln biography

More information

2. E/R Design Considerations

2. E/R Design Considerations 2. E/R Design Considerations 32 What you will learn in this section Relationships cont d: multiplicity, multi-way Design considerations Conversion to SQL 33 Multiplicity of E/R Relationships Multiplicity

More information

SQL Server 2008 Tutorial 3: Database Creation

SQL Server 2008 Tutorial 3: Database Creation SQL Server 2008 Tutorial 3: Database Creation IT 5101 Introduction to Database Systems J.G. Zheng Fall 2011 DDL Action in SQL Server Creating and modifying structures using the graphical interface Table

More information

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1 Basic Concepts :- 1. What is Data? Data is a collection of facts from which conclusion may be drawn. In computer science, data is anything in a form suitable for use with a computer. Data is often distinguished

More information

Databases. Jörg Endrullis. VU University Amsterdam

Databases. Jörg Endrullis. VU University Amsterdam Databases Jörg Endrullis VU University Amsterdam The Relational Model Overview 1. Relational Model Concepts: Schema, State 2. Null Values 3. Constraints: General Remarks 4. Key Constraints 5. Foreign Key

More information

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530 Translation of ER-diagram into Relational Schema Dr. Sunnie S. Chung CIS430/530 Learning Objectives Define each of the following database terms 9.2 Relation Primary key Foreign key Referential integrity

More information

Entity Relationship Data Model. Slides by: Shree Jaswal

Entity Relationship Data Model. Slides by: Shree Jaswal Entity Relationship Data Model Slides by: Shree Jaswal Topics: Conceptual Modeling of a database, The Entity-Relationship (ER) Model, Entity Types, Entity Sets, Attributes, and Keys, Relationship Types,

More information

Relational Model. Course A7B36DBS: Database Systems. Lecture 02: Martin Svoboda Irena Holubová Tomáš Skopal

Relational Model. Course A7B36DBS: Database Systems. Lecture 02: Martin Svoboda Irena Holubová Tomáš Skopal Course A7B36DBS: Database Systems Lecture 02: Relational Model Martin Svoboda Irena Holubová Tomáš Skopal Faculty of Electrical Engineering, Czech Technical University in Prague Outline Logical database

More information

Relational Databases BORROWED WITH MINOR ADAPTATION FROM PROF. CHRISTOS FALOUTSOS, CMU /615

Relational Databases BORROWED WITH MINOR ADAPTATION FROM PROF. CHRISTOS FALOUTSOS, CMU /615 Relational Databases BORROWED WITH MINOR ADAPTATION FROM PROF. CHRISTOS FALOUTSOS, CMU 15-415/615 Roadmap 3 Introduction Integrity constraints (IC) Enforcing IC Querying Relational Data ER to tables Intro

More information

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 3 Relational Model Hello everyone, we have been looking into

More information

Database Management Systems

Database Management Systems Database Management Systems Associate Professor Dr. Raed Ibraheem Hamed University of Human Development, College of Science and Technology Computer Science Department 2015 2016 Department of Computer Science

More information

Exam code: Exam name: Database Fundamentals. Version 16.0

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

More information

SQL Commands & Mongo DB New Syllabus

SQL Commands & Mongo DB New Syllabus Chapter 15 : Computer Science Class XI ( As per CBSE Board) SQL Commands & Mongo DB New Syllabus 2018-19 SQL SQL is an acronym of Structured Query Language.It is a standard language developed and used

More information

Database Systems. Answers

Database Systems. Answers Database Systems Question @ Answers Question 1 What are the most important directories in the MySQL installation? Bin Executable Data Database data Docs Database documentation Question 2 What is the primary

More information

Database Management System 9

Database Management System 9 Database Management System 9 School of Computer Engineering, KIIT University 9.1 Relational data model is the primary data model for commercial data- processing applications A relational database consists

More information

King Fahd University of Petroleum and Minerals

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

More information

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

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

More information