0% found this document useful (0 votes)
38 views21 pages

3 - Relational Data Model

The relational data model represents data in the form of tables called relations. Each relation consists of named columns called attributes and unnamed rows. Attributes can be classified as required or optional, simple or composite, single-valued or multivalued, stored or derived, and can serve as an identifier. Integrity constraints such as domain constraints, entity integrity, and referential integrity are used to maintain accuracy and consistency within and across relations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views21 pages

3 - Relational Data Model

The relational data model represents data in the form of tables called relations. Each relation consists of named columns called attributes and unnamed rows. Attributes can be classified as required or optional, simple or composite, single-valued or multivalued, stored or derived, and can serve as an identifier. Integrity constraints such as domain constraints, entity integrity, and referential integrity are used to maintain accuracy and consistency within and across relations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Relational Data

Model
Relational Data Model
§ Represent data in the form of
tables
§ A named, two-dimensional table
is called a relation
§ Each relation consists of named
columns and an arbitrary number
of unnamed rows
§ A named column is called an
attribute
§ Each row of a relation
corresponds to a record that
contains data
An attribute is characteristic or property of an entity

Classification of Attributes
§ Required vs. Optional Attributes
§ Simple vs. Composite Attributes
§ Single-valued vs. Multivalued Attributes
§ Stored vs. Derived Attributes
§ Identifier

4
Classification of Attributes
§ Required vs. Optional
Attributes

Required–must have a value

Optional–may not have a value

5
Classification of Attributes
Composite
§ Required vs. Optional Attributes
NAME
§ Simple vs. Composite
Attributes
LAST NAME FIRST NAME MID NAME

Composite–has meaningful component parts Simple


(can be broken down) AGE
Simple (or atomic) - cannot be broken
down into smaller components

6
Single-valued–attribute
Classification of Attributes which has only one value

Multivalued–attribute that
§ Required vs. Optional Attributes may take on more than one
§ Simple vs. Composite Attributes value
§ Single-valued vs. Multivalued
Attributes
Single-Valued MultiValued
StudentID STudName BirthDate ContactNo
2019-1234 Julia Cruz 12/02/2005 0917-1111112
8900-7899
0933-7654321

7
Stored–value is provided by user
Classification of Attributes
Derived–value is computed or
§ Required vs. Optional Attributes derived from another attribute/s
§ Simple vs. Composite Attributes
§ Single-valued vs. Multivalued
Attributes
§ Stored vs. Derived Attributes
Stored Derived
StudentID STudName BirthDate Age
2019-1234 Julia Cruz 12/02/2005 15

8
Classification of Attributes Characteristics of
Identifiers
§ Required vs. Optional Attributes §Must not change in value
§ Simple vs. Composite Attributes §Must not be null
§ Single-valued vs. Multivalued §Must be unique
Attributes
§ Stored vs. Derived Attributes
§ Identifier

9
First Mid
Surname
Name Name
Commission Rate
CreditLImit Balance
RepNum

Street FirstName
City Street
LastName CustomerName
City
State
State Rep RepNum
Customer CustomerNum

Zip
Zip

OrderDate

CustomerNum OrderNum
Onhand

Order
Class Description
Price

PartNum
Warehouse Part

NumOrdered PartNum

QuotedPrice OrderNum
m
OrderLine

E-R diagram for the Premiere Products database


Properties of a Relation

1. It has a unique name


2. No multivalued attributes are allowed in a relation
3. Each row is unique
4. Each attribute has a unique name
5. The sequence of columns as well as of rows is insignificant
Relational Keys

Primary Key – an attribute or a combination of attributes that


uniquely identifies each row in a relation

Foreign Key – attribute used to establish the relationship between


two tables. A foreign key in a table/relation always point to the
primary key of another table/relation

Composite key – a key that consists of more than one attribute


We can express the structure of a relation by using a
shorthand notation as follows:

EMPLOYEE(EmpID, Name, DeptName, EmployStatus)


CUSTOMER_T
Cust_ID Cust_Name Cust_Address AGE SEX SALARY

Order_ID Order_Date Cust_ID


------- ORDER_T

Cust_ID is a foreign key in ORDER. It allows an order to be


associated with a particular customer
Integrity Constraints
Rules limiting acceptable values and actions , to facilitate
maintaining the accuracy and integrity of data

§ Domain Constraints

§ Entity Integrity

§ Referential Integrity
Integrity Constraints

Domain Constraints – Domain is a set of values that can be


assigned to an attribute ; a domain definition consists of domain
name, meaning, data type, size and allowable values for the
domain values
Age
The Data Type of Domain includes string, character, integer, time, 18
16
date, currency etc. The value of the attribute must be available in
17
the corresponding domain
15
A
Example: if there is a column (attribute) of integer value then it
cannot contain an alphabet in it, since the attribute must be only
integer values as its domain
Integrity Constraints
Entity Integrity – ensures that every relation
has a valid primary key

The entity integrity constraint states that


primary key value can’t be null Employee
Emp_ID Emp_Name
101 A
This because the primary key value is used to 102 B
identify individual rows in relation/table and 103 C
if the primary key has a null value, then we 104 D
can’t identify these rows. E

A table can contain a null value other than


the primary key field
Integrity Constraints

Referential Integrity – rule that maintains consistency among


the rows of two relations/tables.

The rule states that if there is a foreign key, either each foreign
key value must match a primary key value or the foreign key
value must be null
Foreign Key
Employee Address
Primary Key Emp_ID Emp_Name Age Emp_Add Primary Key Emp_Add City
1 Snowhite 18 A A Quezon
2 Belle 16 B B Makati
3 Mulan 17 C
4 Elsa 15 D D Manila
Integrity Constraints
Key Constraints are the entity set that is used to identify an entity
within its entity set uniquely
A entity set can have multiple keys but out of which one will be the
primary key. A primary key can contain a unique and null value in the
relation\table
Emp_ID
101
102
103
104
102 Not allowed because all rows must be unique
Source:

Modern Database Management


By Hoffer, Ramesh, Topi

You might also like