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

Similar documents
File Processing Approaches

Database Logical Design

Database Logical Design

Normalization (1) IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

Chapter 4. The Relational Model

SQL Server 2008 Tutorial 3: Database Creation

Introduction to Databases

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

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

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

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

Relational Data Model

The Relational Data Model and Relational Database Constraints

3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key

Entity Attribute STUDENT TABLE tuples single domain

Relational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION

CS 377 Database Systems

Introduction to Relational Databases. Introduction to Relational Databases cont: Introduction to Relational Databases cont: Relational Data structure

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

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

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

CS W Introduction to Databases Spring Computer Science Department Columbia University

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

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

ER Model. Objectives (2/2) Electricite Du Laos (EDL) Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 1

Handout 4. Logical Database Modeling, Part 1: Relational Data Model. Transforming EER model to Relational.

The Relational Model

Let s briefly review important EER inheritance concepts

1D D0-541 CIW v5 Database Design Specialist Version 1.7

Normalization in DBMS

Relational Data Model. Christopher Simpkins

The Relational Model and Normalization

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

CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam

DBMS. Relational Model. Module Title?

7) To be considered a composite key, a key must contain at least two attributes. Answer: TRUE

CSC 453 Database Technologies. Tanu Malik DePaul University

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

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

CSE 132A Database Systems Principles

CS275 Intro to Databases

IT360: Applied Database Systems. Slide Set: #2. Relational Model (Chapter 3 Kroenke) The relational model Relational model terminology

8) A top-to-bottom relationship among the items in a database is established by a

Database Management Systems

Test Bank For A Guide To Mysql 1st Edition By Pratt And Last

Link download full of Solution Manual:

The Relational Model

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

Chapter 3. The Relational database design

CS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010

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

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams

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

Constraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2

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

Database Management System 9

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

ECE 650 Systems Programming & Engineering. Spring 2018

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Introduction to Databases

Introduction to Database Systems CSE 414

The Relational Model Constraints and SQL DDL

Introduction to Data Management CSE 344

THE RELATIONAL DATABASE MODEL

King Fahd University of Petroleum and Minerals

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

The Relational Model

FUNCTIONAL DEPENDENCIES CHAPTER , 15.5 (6/E) CHAPTER , 10.5 (5/E)

RELATIONAL DATA MODEL

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

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

Advance Database Management System

ch02 True/False Indicate whether the statement is true or false.

Full file at

Test Bank for A Guide to SQL 9th Edition by Pratt

Fundamentals, Design, and Implementation, 9/e Copyright 2004 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M.

Data Infrastructure IRAP Training 6/27/2016

Level 6 Relational Database Unit 3 Relational Database Development Environment National Council for Vocational Awards C30147 RELATIONAL DATABASE

CS 2451 Database Systems: Relational Data Model

The Relational Model of Data (ii)

COURSE OVERVIEW THE RELATIONAL MODEL. CS121: Relational Databases Fall 2017 Lecture 1

CSE 530A. ER Model to Relational Schema. Washington University Fall 2013

Relational Database Systems Part 01. Karine Reis Ferreira

COURSE OVERVIEW THE RELATIONAL MODEL. CS121: Introduction to Relational Database Systems Fall 2016 Lecture 1

Introduction to Relational Database Concepts. Copyright 2011, Oracle. All rights reserved.

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

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

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language

Introduction to modeling

Introduction to Database Systems. The Relational Data Model

The Relational Model

Introduction to Database Management Systems

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

Introduction to Database Systems. The Relational Data Model. Werner Nutt

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

Overview. Data Integrity. Three basic types of data integrity. Integrity implementation and enforcement. Database constraints Transaction Trigger

A database consists of several tables (relations) AccountNum

Chapter 2 Introduction to Relational Models

What is a Database? CMPSCI 105: Lecture #15 Introduction to Databases. Spreadsheets vs. Databases. One Skill You Will Develop

Transcription:

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 Edgar F. Codd (IBM), 1970 One sentence to summarize relational database model (extremely brief): Data are organized in relations (tables), which are linked by keys (constraints) 3

Relational Model in MS Access Data are organized in relations (tables), and linked by keys. 4

Relation A relation is a two-dimensional table that has some specific characteristics: 1. The table consist of rows and columns 2. Rows contain data about entity instances 3. All values in a row describes the same entity instance 4. Columns contain data about attributes of the entity 5. All values in a column are of the same kind 6. Each row is distinct 7. A cell of the table holds a single value 8. Each column has a unique name 9. The order of the rows is unimportant 10. The order of the columns is unimportant 5

Relation Example (in table view) 6

Non-Relation Examples 7

Terminology Contrast Database industry Table Row Column Academic Relation Tuple Attribute File processing File Record Field 8

Key A key is one or more columns of a relation that is used to uniquely identify a record Primary key Candidate key Alternate key Surrogate key Composite key Foreign key 9

Candidate Key/Primary Key Candidate key The minimum set of column(s) that uniquely identifies a single record (row) Each value in this column is unique in this relation Primary key Is one of the candidate keys chosen to be the identifying key; others become alternate keys Primary Key 10

Primary Key (PK) Primary key is a column/attribute that is used to uniquely identify a record Each value of this key column uniquely identifies a single record (row) There is only ONE primary key for a table Which of the following attribute can uniquely identify a single student? Last Name Full Name Birth date Student Number Social Security Number 11

Composite Key Composite key A composite key contains two or more attributes (columns) All keys can be composite keys Example: FirstName + LastName FirstName + LastName + BirthDate FirstName + LastName + BirthDate + BirthCity 12

Artificial Primary Key/Surrogate Key Sometimes it is difficult to find a natural attribute as a primary key, or it is difficult to use a composite key. A column is created arbitrarily and assign each record a unique number/id Product Number, Product Id, Movie Id, Actor Id, etc. Surrogate Primary Key: the id does not really mean anything. Often such IDs will be generated by database systems. 13

PK Selection Guidelines Do not use a field whose value is frequently changed as PK Look for single-attribute PK first If a PK contains more than 3 columns, consider a surrogate key Don t be limited to sample data; think beyond and consider possible scenarios and requirements 14

Relationship and Foreign Key (FK) Relationship is how tables (relations) are linked It is defined by the foreign key (FK) constraint A foreign key references a primary key (or any other unique keys) in another table This pair of keys are of the same kind (may be of different name) 15

Relationship and FK Example Primary Key (PK) Primary Key (PK) Foreign Key 1 (FK 1) Foreign Key 2 (FK 2) Composite primary key: OrderNumber+SKU 16

Foreign Key Example Department DeptID DeptName Location Primary Key Foreign Key Employee EmpID EmpName Department Primary Key and Foreign Key are of the same type (string, number, etc.) and length, but they do not necessarily have the same name. 17

Relationship in MS Access 18

Relationship in SQL Server Database Primary Key (PK) is indicated by a key symbol Note: in SQL Server, the line ends do not exactly point to the right column Foreign Key (FK) side is indicated by a infinite loop symbol. 19

Database Structure Representation Graphic/diagram style Department DeptID DeptName Location Employee EmpID EmpName Department Primary Key: underscored Text style Department (DeptID, DeptName, Location) Employee (EmpID, EmpName, Department) FK: Department Department.DeptID Foreign Key: italicized, and additional definition is just below the table definition 20

Schema in Relational Databases Schema is the structure described in a formal language supported by the database management system (DBMS) It s a kind of metadata Relational database schema commonly defines Tables: name, primary key Columns: name, data type, size, value range, etc. Constraints: all kinds of keys Other structures 21

Common Data Types Numeric Integer: 0, 4, 20, -200 Decimal: 3.14, 4.0 Character/String Character: 'A', 't', '4', '$' String/Text: 'cis 3730' Date/Time Date: 8/23/2010 Date/Time: 8/23/2010 12:30:00AM Bit/Boolean Yes/No, true/false, 0/1 22

Null Value Null means A value is inapplicable: Fax_Number = Null A value is unknown: Stud_Grade = Null Null does NOT mean Zero, or blank space No primary key (or part of a composite primary key) can be NULL NULL in SQL Server database tables 23

Data Integrity Data integrity: the correctness or quality of data Relational databases ensure data integrity in 3 aspects: Entity Integrity: no empty or duplicate rows in a table. Use primary key constraints Referential integrity: rows cannot be deleted or modified, if they are referenced by other records in other tables Use foreign key constraints Domain Integrity: valid entries for a given column is restricted by the type, the format, or the range of possible values Use Check rules on columns 24

Referential Integrity Every value of a foreign key must match a value of the primary key or be NULL Example (slide #16) In the Employee table, Department is a foreign key (linked to the Department table where DeptID is the primary key). Then every value of Department in the Employee table must exist in the Department table first, otherwise the data will be rejected, if the referential integrity is enforced. 25

Enforcing Referential Integrity in Databases In Microsoft Access In SQL Server 26

Summary Key concepts Relation (and its 10 features) Relational model terminologies: Row, column, record, field, attribute Keys Primary key, candidate key, surrogate key, composite key, foreign key Database schema and metadata Basic data types: number, character, date, bit, NULL Data integrity: entity, domain, referential How relational database systems ensure these three kinds of data integrity? Key skills Be able to explain if a table is not a relation Identify the primary key, composite primary key, candidate keys, and foreign keys of a given table/relation. Understand and can use the graphical and text representation of database structures: tables, columns and keys. 27