SlideShare a Scribd company logo
1 of 52
Download to read offline
RELATIONAL DATA MODEL
PART 1	
  
DFC2033 Database System
Learning outcome
1
¨  Define database
¨  Describe component of database table.
¤  Record (Tuple)
¤  Attribute (Field)
¤  Domain
¤  Degree
¤  Cardinality
¨  Describe characteristic of relation scheme.
¤  Relation Name
¤  Attribute Name
¤  Domain
Learning outcomes
2
¨  Describe the relation instance
¨  Identify relation keys:
¤  Primary Key
¤  Candidate Key
¤  Foreign Key
¨  Explain Relational Model Relationship
¤  One to Many
¤  Many to Many
¤  Self Referencing
¨  Create connections between tables.
¨  Apply Integrity rules to several tables in a given database.
Database
3
¨  Definition
¤  Database is a shared, integrated computer structure that houses
the collection of:
n  End User Data : users’ data
n  Metadata: description about data (description about table, attributes
etc.)
¨  Data
¤  Raw facts about, unprocessed facts.
¤  e.g.: Aminah, 0102539937
¨  Description
¤  Store metadata- data about data
¤  Know as System Catalog / data dictionary
¤  e.g.: Name : VARCHAR(10)
Database
4
¨  Example of database encounter in daily life:
¤  Airline reservation
¤  Purchasing from supermarket
¤  Using local library
Example of Database
5
Relational Database Model
6
¨  First proposed by Dr. E.F. Codd of IBM Research in 1970
¨  Represent database as a collection of relation.
¨  Informally, each relation looks like a table of values.
¨  Represent database as a collections of relations.
¨  Relational database matches data by using common
characteristics found within the data set.
¨  The resulting groups of data are organized and are much
easier for people to understand.
Relational Database Model
7
¨  Basic Structure
¤  Implemented through Relational DBMS (RDBMS)
¤  RDBMS manage the complexity of physical implementation.
¤  Users see database as a collection of tables in which data are
stored.
¤  Tables are also known as Relation.
¤  Tables contains Attributes.
¤  Attributes are a set of characteristics of the table.
¤  Tables are related to each other through some shared attributes.
¤  The relationship type is shown in Relational Schema.
Relational Database Model
8
Component of database table
9
¨  Entity
¨  Attribute/Column (Field)
¨  Domain
¨  Degree
¨  Record/Row (Tuple)
¨  Cardinality
Entity
10
¨  Things or object in real world with independent
existence.
¨  An entity may be object with:
¤  physical existence : person, car, house, employed, etc.
¤  conceptual existence : job, course, event.
Attribute
11
¨  Attribute (Field)
¤  Each entity has certain characteristics known as
attributes.
¤  Named column of relation.
¤  Example : an EMPLOYEE entity maybe describe by
employee's name, age, address, salary and job.
¤  Used to hold information about the objects to be
represented in database.
Simple & Composite Attributes
12
¨  Simple Attributes
¤  Attribute that cannot be further divided
¤  Simple (Atomic) attributes.
n  Age, City, Postal Code
¨  Composite Attributes
¤  Comprise of more than one attributes.
n  Can be divided into smaller subparts, which represent more
basic attributes with independent meaning.
n  Address consist of streetNumber, postalCode, city
Single valued & Multivalued Attributes
13
¨  Single Valued Attributes
¤  Can only have one value for the particular entity.
¤  Eg: A student can have only one IC number
¨  Multivalued Attributes
¤  Attributes that can have many values.
¤  Eg: A student can have many certificate such as
PMR, SPM, MLVK, etc.
Stored & Derived Attributes
14
¨  Stored Attributes
¤  The date_of_birth is the stored attribute.
¨  Derived attributes
¤  Can be computed from other attributes
¤  Example: age is derived from date_of_birth.
¤  Age is called derived attribute,
Null values
15
¨  In some cases, particular entity may not have an
applicable value for an attribute.
¨  Two cases:
1.  The attribute value is missing.
n  E.g.: Height attribute is NULL.
2.  It is not known whether the attribute value exist.
n  College degree – some people may have it and some not.
¨  Therefore, NULL value has to be created
Domain
16
¨  Set of possible values for an attribute.
¨  Each simple attribute of entity is associated with
value set (domain of values)
¨  It specify the sets value that may be assigned to
that attribute for each individual entity.
¨  Example given an attribute named GENDER, the
domains are MALE and FEMALE.
¨  Formally written as: GENDER = {MALE, FEMALE}
Degree
17
¨  Degree
¤  The degree of relation is the number of attributes it
contains.
¤  For example, Student has four attributes, or degree
four.
Tuple
18
¨  Record (Tuple)
¨  Row of a relation.
Cardinality
19
¨  Cardinality
¤  The number of tuples(rows) its contains.
¤  If Branch relation have 5 number of tuples, the
cardinality of Branch relation is 5.
¤  Change as the number of tuples is added or deleted.
Example
20
Relational Scheme
22
¨  Named relation defined by a set of attribute and
domain name pairs.
¨  Common convention:
¤  RelationName (attribute_1, attribute_2,…..,
attribute_n)
¨  Example:
¤  Branch (branchNo, street, city, postcode)
Characteristics of Relation Scheme
23
¨  What is Relation Schema?
¤  A named of a relation defined by a set of attributes
and domain name pairs.
¨  Relation name
¤  Relation name is distinct from all other relation names in
relational schema.
¤  Cannot have two Student relation in the database.
Characteristics of relation scheme
24
¨  Attribute name
¤  Each attribute has a distinct name.
¤  Order of attributes has no significance.
¤  Order of tuples has no significance, theoretically.
¨  Domains
¤  Values of an attribute are all from the same domain.
Characteristics of relation scheme
25
Different order of tuple don’t have any significance
Relational Database schema
26
¨  A sets of relation schema.
¨  The example shows the database schema for COMPANY =
{EMPLOYEE, DEPARTMENT, DEPENDENT, PROJECT}
Relation
Schema
DB
Schema
Relational Database schema
27
¨  The relation schema normally represented as
follows:
¨  The primary key is underlined.
EMPLOYEE { SSN, FNAME, LNAME, MINIT, BDATE, ADDRESS, SEX,
SALARY, SUPERSSN,DNO }
DEPARTMENT { DNUM, DNAME, MGRSSN, MGRSTTDATE }
Relation instance
28
¨  A tuple at a specific moment of time
¨  Eg: Branch (BranchNo, Street, City, PostalCode )
¨  The relation instance for branch is:
¤  (B005, 55 Jln Dobi, Johor Bahru, 80100)
¤  (B006, 55 Jalan Perai, Johor Bahru, 80000)
¨  The relation instance change when tuple is updated,
deleted or inserted.
Group discussion
29
¨  Create a relational database schema for Politeknik
Balik Pulau.
Relation Keys
30
¨  Refers to the important attribute in an entity.
¨  Determine the uniqueness of an row in given table.
¨  Identifiers for each rows.
¨  An attribute or more than one attributes can be
declared as keys depending on situations.
¨  Types of keys:
¤  Primary Key
¤  Candidate Key
¤  Alternate Key
¤  Foreign key
Primary Key
31
¨  Is an attributes that uniquely identify each rows.
¨  Each table must have primary key.
¨  Cannot be NULL value to maintain Entity Integrity.
¨  Primary key is the one that officially declared as the
row identifier inside a specific table.
¨  Candidate keys for table Student:
¨  Eg: studentID for Table Students
Candidate key
32
¨  A candidate key is a single field or the least combination of
fields that uniquely identifies each record in the table.
¨  There can be more than one candidate keys in a relation.
¨  Criteria for the candidate keys:
¤  It must contain unique values
¤  It must not contain null values
¤  It contains the minimum number of fields to ensure uniqueness
¤  It must uniquely identify each record in the table
Candidate key
33
¨  Candidate Keys:
¤  {StudentID}
¤  {firstName,lastName}
Candidate key
34
¨  However, the instance of relation cannot be used to
proved attributes or combination of attributes is a
candidate key.
¨  What happen if another person has name James
McCloud as the first and last name?
¨  Identifying the candidate keys require that we know
“the real world” meaning of the attribute involved.
Alternate key
¨  An alternate key is any candidate key that is not
primary key.
¨  Alternate keys are sometimes referred as
secondary keys.
Foreign Key
35
¨  Attribute is an attributes whose value match the primary
key values in related tables.
¨  Creates a relationship between relations
Example
36
¨  Branch (branchNo, street, city, postCode)
¨  Staff (staffNo, fName, lName, position, sex, DOB, salary,
branchNo)
¨  FK à branchNo references Branch (branchNo)
Component in relational schema
37
Group discussion
38
DriverID dFName dLName
D456 Jane Watt
D666 Karen Black
D957 Steven Smith
D344 Tom Jones
ClientID FName cEmail cAddress
C3034 Anne Way 111 Storie Road
C089 Mark Fields 120 Lady Jane
C019 Anne Brown 13 Renfrew Road
C039 Karen Ways 34 High Street
DriverID ClientID pickupDate
D456 C3034 2/1/10
D456 C089 2/1/10
D666 C3034 2/1/10
D344 C039 2/1/10
For each table, find:
1.  Two candidate keys
2.  Primary Key
3.  Foreign Key
Integrity rules
39
¨  To have a good design, a database must have
integrity rules.
¨  Constraint or restriction that apply to all instances of
the database.
¨  Integrity rules consists of:
¤  Entity Integrity
¤  Referential Integrity
Entity integrity
40
¨  Requirement
¤  All Primary Key entries are unique, and no part of a primary
key may be NULL.
¨  Purpose
¤  Guarantee that each entity will have a unique identity and
ensures that for each key value can properly refer primary
key values.
¨  Examples:
¤  INVOICE, no invoice can have a duplicate number, nor can it
be NULL.
¤  All invoices are UNIQUELY identified by their invoice
number.
Referential integrity
41
¨  Requirement
¤  A Foreign Key may have either a NULL entry, as long as it is not a part
of its table’s primary key or an entry that matches the primary key
value in a table to which is related. (Every non-null foreign key value
must reference an existing primary key value)
¨  Purpose
¤  Makes it possible for an attribute NOT to have a corresponding value,
but will be impossible to have an invalid entry.
¤  The enforcement of the referential integrity rules makes it impossible to
delete a row in one table whose primary keys has mandatory matching
foreign key values on another table.
¨  Examples:
¤  A customer might not (yet) have an assigned customer sales
representative (CSR) number, but it will be impossible to have an invalid
CSR number.
Example
42
¤  Branch and Staff Relation.
¤  It is not possible to create staff record with branchNo
B025, unless there is already record for branch B025
in Branch relation.
¤  However, we should be able to create new staff
record with NULL branch number to allow the situation
where a new member staff has joined the company but
has not yet assigned to a particular Branch.
Referential integrity
43
Relational Model Relationship
44
¨  An association between entities.
¨  Entities that participate in the relationship are
called participants.
¨  Specifies how many instances of an entity relate to
one instance of another entity.
¨  Types:
¤  One to Many (1:M) Relationship
¤  Many to Many (M:N) Relationship
¤  Self Referencing Relationship
One to many (1:M)
45
¨  Table A may have many linked records in Table B
¨  But each record in Table B may have only one
corresponding record in Table A.
One to many (1:M)
46
¨  Example:
¤  A database in company keep track the information
about the employee and their dependent. Each
employee can have one or more dependent and each
dependent belongs to one employee only.
Many to many (m:N)
47
¨  Table A may have many linked records in Table B
¨  Table B may have only many record corresponding
record in Table A.
¨  M: N relationship is not a good choice in database.
¨  Normally when we have M:N relationship, we have
to separate into 1:M relationship.
Many to many (m:N)
48
¨  Example:
¤  A course can be taken by many students and the
students can take as many courses as they want.
Self referencing
49
¨  Relationship to itself.
¨  E.g. Employee reports to Employee
Group discussion
50
A company has several departments. Each department
has a supervisor and at least one employee. Employees
must be assigned to at least one department. Projects will
be given to the employee and it will be done in a group.
At least one employee is assigned to one project or more.
The important data files are the names of the
departments, projects, supervisors and employees, as well
as the supervisor and employee number, department
code and unique project number.
¨  Identify the entity.
¨  Identify the relationship.
Chapter 2 Relational Data Model-part1

More Related Content

What's hot

All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbmsNaresh Kumar
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMSkoolkampus
 
Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)Ravinder Kamboj
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational modelChirag vasava
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database DesignArchit Saxena
 
Basic Concept of Database
Basic Concept of DatabaseBasic Concept of Database
Basic Concept of DatabaseMarlon Jamera
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data ModelSmriti Jain
 
Types of Database Models
Types of Database ModelsTypes of Database Models
Types of Database ModelsMurassa Gillani
 
Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)Vidyasagar Mundroy
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLEVraj Patel
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMSkoolkampus
 
Lecture 01 introduction to database
Lecture 01 introduction to databaseLecture 01 introduction to database
Lecture 01 introduction to databaseemailharmeet
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalizationdaxesh chauhan
 

What's hot (20)

All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbms
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)Architecture of dbms(lecture 3)
Architecture of dbms(lecture 3)
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
Database design
Database designDatabase design
Database design
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
 
DBMS Keys
DBMS KeysDBMS Keys
DBMS Keys
 
Basic Concept of Database
Basic Concept of DatabaseBasic Concept of Database
Basic Concept of Database
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
 
Relational model
Relational modelRelational model
Relational model
 
Types of Database Models
Types of Database ModelsTypes of Database Models
Types of Database Models
 
Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)Database Systems - Relational Data Model (Chapter 2)
Database Systems - Relational Data Model (Chapter 2)
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMS
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
Lecture 01 introduction to database
Lecture 01 introduction to databaseLecture 01 introduction to database
Lecture 01 introduction to database
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalization
 
Database schema
Database schemaDatabase schema
Database schema
 

Viewers also liked

Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2Eddyzulham Mahluzydde
 
Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3Eddyzulham Mahluzydde
 
Chapter 1 Fundamentals of Database Management System
Chapter 1 Fundamentals of Database Management SystemChapter 1 Fundamentals of Database Management System
Chapter 1 Fundamentals of Database Management SystemEddyzulham Mahluzydde
 
Fundamentals of Database system
Fundamentals of Database systemFundamentals of Database system
Fundamentals of Database systemphilipsinter
 
Chapter 5 Database Transaction Management
Chapter 5 Database Transaction ManagementChapter 5 Database Transaction Management
Chapter 5 Database Transaction ManagementEddyzulham Mahluzydde
 
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ARADHYAYANA
 
Oxford Scholarship Online Access
Oxford Scholarship Online AccessOxford Scholarship Online Access
Oxford Scholarship Online AccessAnwarul Islam, PhD
 
Software Engineering - 01. Introduction
Software Engineering - 01. IntroductionSoftware Engineering - 01. Introduction
Software Engineering - 01. IntroductionArry Arman
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relationalJafar Nesargi
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...Mustafa Kamel Mohammadi
 
Ch01 database-conceptsppt4207
Ch01 database-conceptsppt4207Ch01 database-conceptsppt4207
Ch01 database-conceptsppt4207Burhan Chaudhry
 
Software Engineering - Introduction and Motivation (Marcello Thiry)
Software Engineering - Introduction and Motivation (Marcello Thiry)Software Engineering - Introduction and Motivation (Marcello Thiry)
Software Engineering - Introduction and Motivation (Marcello Thiry)Marcello Thiry
 
Database normalization
Database normalizationDatabase normalization
Database normalizationEdward Blurock
 
Bsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architectureBsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architectureRai University
 
2 database system concepts and architecture
2 database system concepts and architecture2 database system concepts and architecture
2 database system concepts and architectureKumar
 
introduction to database
 introduction to database introduction to database
introduction to databaseAkif shexi
 

Viewers also liked (20)

Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2
 
Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3
 
Chapter 1 Fundamentals of Database Management System
Chapter 1 Fundamentals of Database Management SystemChapter 1 Fundamentals of Database Management System
Chapter 1 Fundamentals of Database Management System
 
Fundamentals of Database system
Fundamentals of Database systemFundamentals of Database system
Fundamentals of Database system
 
Chapter 5 Database Transaction Management
Chapter 5 Database Transaction ManagementChapter 5 Database Transaction Management
Chapter 5 Database Transaction Management
 
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
 
Chapter 3 Entity Relationship Model
Chapter 3 Entity Relationship ModelChapter 3 Entity Relationship Model
Chapter 3 Entity Relationship Model
 
Crj 3 1-b
Crj 3 1-bCrj 3 1-b
Crj 3 1-b
 
Oxford Scholarship Online Access
Oxford Scholarship Online AccessOxford Scholarship Online Access
Oxford Scholarship Online Access
 
Software Engineering - 01. Introduction
Software Engineering - 01. IntroductionSoftware Engineering - 01. Introduction
Software Engineering - 01. Introduction
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
 
Ch01 database-conceptsppt4207
Ch01 database-conceptsppt4207Ch01 database-conceptsppt4207
Ch01 database-conceptsppt4207
 
Software Engineering - Introduction and Motivation (Marcello Thiry)
Software Engineering - Introduction and Motivation (Marcello Thiry)Software Engineering - Introduction and Motivation (Marcello Thiry)
Software Engineering - Introduction and Motivation (Marcello Thiry)
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
Bsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architectureBsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architecture
 
2 database system concepts and architecture
2 database system concepts and architecture2 database system concepts and architecture
2 database system concepts and architecture
 
Denormalization
DenormalizationDenormalization
Denormalization
 
introduction to database
 introduction to database introduction to database
introduction to database
 

Similar to Chapter 2 Relational Data Model-part1

Similar to Chapter 2 Relational Data Model-part1 (20)

NMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.pptNMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.ppt
 
DBMS Part-2.pdf
DBMS Part-2.pdfDBMS Part-2.pdf
DBMS Part-2.pdf
 
RDBMS
RDBMSRDBMS
RDBMS
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Unit04 dbms
Unit04 dbmsUnit04 dbms
Unit04 dbms
 
Relation model part 1
Relation model part 1Relation model part 1
Relation model part 1
 
Eer >r.model
Eer >r.modelEer >r.model
Eer >r.model
 
Download different material from slide share
Download different material from slide shareDownload different material from slide share
Download different material from slide share
 
3_Relational_Model.pdf
3_Relational_Model.pdf3_Relational_Model.pdf
3_Relational_Model.pdf
 
19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf
 
Db lec 02_new
Db lec 02_newDb lec 02_new
Db lec 02_new
 
Relational model
Relational modelRelational model
Relational model
 
Relational model
Relational modelRelational model
Relational model
 
3 relational model
3 relational model3 relational model
3 relational model
 
DBMS Unit-2.pdf
DBMS Unit-2.pdfDBMS Unit-2.pdf
DBMS Unit-2.pdf
 
Relational database- Fundamentals
Relational database- FundamentalsRelational database- Fundamentals
Relational database- Fundamentals
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
Relational model
Relational modelRelational model
Relational model
 
DBMS-Unit-2.pptx
DBMS-Unit-2.pptxDBMS-Unit-2.pptx
DBMS-Unit-2.pptx
 
DATABASE DESIGN.pptx
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
 

Recently uploaded

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 

Recently uploaded (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 

Chapter 2 Relational Data Model-part1

  • 1. RELATIONAL DATA MODEL PART 1   DFC2033 Database System
  • 2. Learning outcome 1 ¨  Define database ¨  Describe component of database table. ¤  Record (Tuple) ¤  Attribute (Field) ¤  Domain ¤  Degree ¤  Cardinality ¨  Describe characteristic of relation scheme. ¤  Relation Name ¤  Attribute Name ¤  Domain
  • 3. Learning outcomes 2 ¨  Describe the relation instance ¨  Identify relation keys: ¤  Primary Key ¤  Candidate Key ¤  Foreign Key ¨  Explain Relational Model Relationship ¤  One to Many ¤  Many to Many ¤  Self Referencing ¨  Create connections between tables. ¨  Apply Integrity rules to several tables in a given database.
  • 4. Database 3 ¨  Definition ¤  Database is a shared, integrated computer structure that houses the collection of: n  End User Data : users’ data n  Metadata: description about data (description about table, attributes etc.) ¨  Data ¤  Raw facts about, unprocessed facts. ¤  e.g.: Aminah, 0102539937 ¨  Description ¤  Store metadata- data about data ¤  Know as System Catalog / data dictionary ¤  e.g.: Name : VARCHAR(10)
  • 5. Database 4 ¨  Example of database encounter in daily life: ¤  Airline reservation ¤  Purchasing from supermarket ¤  Using local library
  • 7. Relational Database Model 6 ¨  First proposed by Dr. E.F. Codd of IBM Research in 1970 ¨  Represent database as a collection of relation. ¨  Informally, each relation looks like a table of values. ¨  Represent database as a collections of relations. ¨  Relational database matches data by using common characteristics found within the data set. ¨  The resulting groups of data are organized and are much easier for people to understand.
  • 8. Relational Database Model 7 ¨  Basic Structure ¤  Implemented through Relational DBMS (RDBMS) ¤  RDBMS manage the complexity of physical implementation. ¤  Users see database as a collection of tables in which data are stored. ¤  Tables are also known as Relation. ¤  Tables contains Attributes. ¤  Attributes are a set of characteristics of the table. ¤  Tables are related to each other through some shared attributes. ¤  The relationship type is shown in Relational Schema.
  • 10. Component of database table 9 ¨  Entity ¨  Attribute/Column (Field) ¨  Domain ¨  Degree ¨  Record/Row (Tuple) ¨  Cardinality
  • 11. Entity 10 ¨  Things or object in real world with independent existence. ¨  An entity may be object with: ¤  physical existence : person, car, house, employed, etc. ¤  conceptual existence : job, course, event.
  • 12. Attribute 11 ¨  Attribute (Field) ¤  Each entity has certain characteristics known as attributes. ¤  Named column of relation. ¤  Example : an EMPLOYEE entity maybe describe by employee's name, age, address, salary and job. ¤  Used to hold information about the objects to be represented in database.
  • 13. Simple & Composite Attributes 12 ¨  Simple Attributes ¤  Attribute that cannot be further divided ¤  Simple (Atomic) attributes. n  Age, City, Postal Code ¨  Composite Attributes ¤  Comprise of more than one attributes. n  Can be divided into smaller subparts, which represent more basic attributes with independent meaning. n  Address consist of streetNumber, postalCode, city
  • 14. Single valued & Multivalued Attributes 13 ¨  Single Valued Attributes ¤  Can only have one value for the particular entity. ¤  Eg: A student can have only one IC number ¨  Multivalued Attributes ¤  Attributes that can have many values. ¤  Eg: A student can have many certificate such as PMR, SPM, MLVK, etc.
  • 15. Stored & Derived Attributes 14 ¨  Stored Attributes ¤  The date_of_birth is the stored attribute. ¨  Derived attributes ¤  Can be computed from other attributes ¤  Example: age is derived from date_of_birth. ¤  Age is called derived attribute,
  • 16. Null values 15 ¨  In some cases, particular entity may not have an applicable value for an attribute. ¨  Two cases: 1.  The attribute value is missing. n  E.g.: Height attribute is NULL. 2.  It is not known whether the attribute value exist. n  College degree – some people may have it and some not. ¨  Therefore, NULL value has to be created
  • 17. Domain 16 ¨  Set of possible values for an attribute. ¨  Each simple attribute of entity is associated with value set (domain of values) ¨  It specify the sets value that may be assigned to that attribute for each individual entity. ¨  Example given an attribute named GENDER, the domains are MALE and FEMALE. ¨  Formally written as: GENDER = {MALE, FEMALE}
  • 18. Degree 17 ¨  Degree ¤  The degree of relation is the number of attributes it contains. ¤  For example, Student has four attributes, or degree four.
  • 20. Cardinality 19 ¨  Cardinality ¤  The number of tuples(rows) its contains. ¤  If Branch relation have 5 number of tuples, the cardinality of Branch relation is 5. ¤  Change as the number of tuples is added or deleted.
  • 22. Relational Scheme 22 ¨  Named relation defined by a set of attribute and domain name pairs. ¨  Common convention: ¤  RelationName (attribute_1, attribute_2,….., attribute_n) ¨  Example: ¤  Branch (branchNo, street, city, postcode)
  • 23. Characteristics of Relation Scheme 23 ¨  What is Relation Schema? ¤  A named of a relation defined by a set of attributes and domain name pairs. ¨  Relation name ¤  Relation name is distinct from all other relation names in relational schema. ¤  Cannot have two Student relation in the database.
  • 24. Characteristics of relation scheme 24 ¨  Attribute name ¤  Each attribute has a distinct name. ¤  Order of attributes has no significance. ¤  Order of tuples has no significance, theoretically. ¨  Domains ¤  Values of an attribute are all from the same domain.
  • 25. Characteristics of relation scheme 25 Different order of tuple don’t have any significance
  • 26. Relational Database schema 26 ¨  A sets of relation schema. ¨  The example shows the database schema for COMPANY = {EMPLOYEE, DEPARTMENT, DEPENDENT, PROJECT} Relation Schema DB Schema
  • 27. Relational Database schema 27 ¨  The relation schema normally represented as follows: ¨  The primary key is underlined. EMPLOYEE { SSN, FNAME, LNAME, MINIT, BDATE, ADDRESS, SEX, SALARY, SUPERSSN,DNO } DEPARTMENT { DNUM, DNAME, MGRSSN, MGRSTTDATE }
  • 28. Relation instance 28 ¨  A tuple at a specific moment of time ¨  Eg: Branch (BranchNo, Street, City, PostalCode ) ¨  The relation instance for branch is: ¤  (B005, 55 Jln Dobi, Johor Bahru, 80100) ¤  (B006, 55 Jalan Perai, Johor Bahru, 80000) ¨  The relation instance change when tuple is updated, deleted or inserted.
  • 29. Group discussion 29 ¨  Create a relational database schema for Politeknik Balik Pulau.
  • 30. Relation Keys 30 ¨  Refers to the important attribute in an entity. ¨  Determine the uniqueness of an row in given table. ¨  Identifiers for each rows. ¨  An attribute or more than one attributes can be declared as keys depending on situations. ¨  Types of keys: ¤  Primary Key ¤  Candidate Key ¤  Alternate Key ¤  Foreign key
  • 31. Primary Key 31 ¨  Is an attributes that uniquely identify each rows. ¨  Each table must have primary key. ¨  Cannot be NULL value to maintain Entity Integrity. ¨  Primary key is the one that officially declared as the row identifier inside a specific table. ¨  Candidate keys for table Student: ¨  Eg: studentID for Table Students
  • 32. Candidate key 32 ¨  A candidate key is a single field or the least combination of fields that uniquely identifies each record in the table. ¨  There can be more than one candidate keys in a relation. ¨  Criteria for the candidate keys: ¤  It must contain unique values ¤  It must not contain null values ¤  It contains the minimum number of fields to ensure uniqueness ¤  It must uniquely identify each record in the table
  • 33. Candidate key 33 ¨  Candidate Keys: ¤  {StudentID} ¤  {firstName,lastName}
  • 34. Candidate key 34 ¨  However, the instance of relation cannot be used to proved attributes or combination of attributes is a candidate key. ¨  What happen if another person has name James McCloud as the first and last name? ¨  Identifying the candidate keys require that we know “the real world” meaning of the attribute involved.
  • 35. Alternate key ¨  An alternate key is any candidate key that is not primary key. ¨  Alternate keys are sometimes referred as secondary keys.
  • 36. Foreign Key 35 ¨  Attribute is an attributes whose value match the primary key values in related tables. ¨  Creates a relationship between relations
  • 37. Example 36 ¨  Branch (branchNo, street, city, postCode) ¨  Staff (staffNo, fName, lName, position, sex, DOB, salary, branchNo) ¨  FK à branchNo references Branch (branchNo)
  • 39. Group discussion 38 DriverID dFName dLName D456 Jane Watt D666 Karen Black D957 Steven Smith D344 Tom Jones ClientID FName cEmail cAddress C3034 Anne Way 111 Storie Road C089 Mark Fields 120 Lady Jane C019 Anne Brown 13 Renfrew Road C039 Karen Ways 34 High Street DriverID ClientID pickupDate D456 C3034 2/1/10 D456 C089 2/1/10 D666 C3034 2/1/10 D344 C039 2/1/10 For each table, find: 1.  Two candidate keys 2.  Primary Key 3.  Foreign Key
  • 40. Integrity rules 39 ¨  To have a good design, a database must have integrity rules. ¨  Constraint or restriction that apply to all instances of the database. ¨  Integrity rules consists of: ¤  Entity Integrity ¤  Referential Integrity
  • 41. Entity integrity 40 ¨  Requirement ¤  All Primary Key entries are unique, and no part of a primary key may be NULL. ¨  Purpose ¤  Guarantee that each entity will have a unique identity and ensures that for each key value can properly refer primary key values. ¨  Examples: ¤  INVOICE, no invoice can have a duplicate number, nor can it be NULL. ¤  All invoices are UNIQUELY identified by their invoice number.
  • 42. Referential integrity 41 ¨  Requirement ¤  A Foreign Key may have either a NULL entry, as long as it is not a part of its table’s primary key or an entry that matches the primary key value in a table to which is related. (Every non-null foreign key value must reference an existing primary key value) ¨  Purpose ¤  Makes it possible for an attribute NOT to have a corresponding value, but will be impossible to have an invalid entry. ¤  The enforcement of the referential integrity rules makes it impossible to delete a row in one table whose primary keys has mandatory matching foreign key values on another table. ¨  Examples: ¤  A customer might not (yet) have an assigned customer sales representative (CSR) number, but it will be impossible to have an invalid CSR number.
  • 43. Example 42 ¤  Branch and Staff Relation. ¤  It is not possible to create staff record with branchNo B025, unless there is already record for branch B025 in Branch relation. ¤  However, we should be able to create new staff record with NULL branch number to allow the situation where a new member staff has joined the company but has not yet assigned to a particular Branch.
  • 45. Relational Model Relationship 44 ¨  An association between entities. ¨  Entities that participate in the relationship are called participants. ¨  Specifies how many instances of an entity relate to one instance of another entity. ¨  Types: ¤  One to Many (1:M) Relationship ¤  Many to Many (M:N) Relationship ¤  Self Referencing Relationship
  • 46. One to many (1:M) 45 ¨  Table A may have many linked records in Table B ¨  But each record in Table B may have only one corresponding record in Table A.
  • 47. One to many (1:M) 46 ¨  Example: ¤  A database in company keep track the information about the employee and their dependent. Each employee can have one or more dependent and each dependent belongs to one employee only.
  • 48. Many to many (m:N) 47 ¨  Table A may have many linked records in Table B ¨  Table B may have only many record corresponding record in Table A. ¨  M: N relationship is not a good choice in database. ¨  Normally when we have M:N relationship, we have to separate into 1:M relationship.
  • 49. Many to many (m:N) 48 ¨  Example: ¤  A course can be taken by many students and the students can take as many courses as they want.
  • 50. Self referencing 49 ¨  Relationship to itself. ¨  E.g. Employee reports to Employee
  • 51. Group discussion 50 A company has several departments. Each department has a supervisor and at least one employee. Employees must be assigned to at least one department. Projects will be given to the employee and it will be done in a group. At least one employee is assigned to one project or more. The important data files are the names of the departments, projects, supervisors and employees, as well as the supervisor and employee number, department code and unique project number. ¨  Identify the entity. ¨  Identify the relationship.