0% found this document useful (0 votes)
17 views55 pages

Session 1

Uploaded by

kennedywong3399
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views55 pages

Session 1

Uploaded by

kennedywong3399
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 55

Course : ISYS6123 – Introduction to Database System

Year : 2022

Introduction to Databases
and The Relational Model
Session 1
LEARNING OUTCOME

• LO 1: Describe concepts, terminologies, environment, and

relational model in database system


ACKNOWLEDGEMENT

• These slides have been

adapted from Connolly, T., &

Begg, C. (2015). Database

Systems: A Practical

Approach to Design,

Implementation, and

Management. 6th edition.

Pearson Education. USA.

ISBN: 978-1-292-06118-4,

Chapter 1&4
LEARNING OBJECTIVES

Students able to describe about:


•Some common uses of database systems
•Traditional file-based systems
•Database Approach
•Components of DBMS Environment
•Roles in Database Environment
•History of Database Management System (DBMS)
•Terminology of relational model
•Integrity constraints

vtraining-msuhandi.blogspot.com
Some common uses of database
systems
Examples of Database Applications

• Purchases from the supermarket

• Purchases using your credit card

• Booking a holiday at the travel agents

• Using the local library

• Taking out insurance

• Renting a video

• Using the Internet

• Studying at university
jeru.web.id
Purchases from the
supermarket

• A bar code reader to scan each item → to find out the

price & reduce the stock

• Automatically place an order of an item which has

reorder level falls below the specific threshold

• Check the availability of the item

www.bbc.co.uk
Purchases using your credit card

• To check sufficient credit left

based on credit limit.

• To authorize the credit card (It is

not on the list of stolen or lost

cards).

• To send out monthly statements

indianexpress.com
• To credit accounts when payment

is received.
Booking a holiday at the travel agents

• To ensure no overbook the same holiday or the

seats on the flight.

• The travel agent may have another, usually

separate, database for invoicing.

www.parenting-blog.net
Using the local library

• A computerized index to find a book based on its title, or its authors, or its

subject area.

• Able to handle book reservations and give notifications when the book is

available.

• Able to sends reminders if the borrowers have failed to return books by the

due date.

• A bar code reader or RFID (Radio Frequency Identification), which is used to

keep track of books coming in and going out of the library.

www.bbc.co.uk
Studying at university

• To store information about the student:

 the enrolled courses

 the grant

 exam results

• The details relating to the next year’s

admissions.

• The details of the staff:

 personal details

 salary-related details for the payroll

office
Traditional File-Based System
File-Based Systems

• Collection of application programs that perform services for

the end users (e.g. reports).

• Each program defines and manages its own data.

ictlabs-summer-school.sics.se
File-Based Processing
Limitations of File-Based
Approach
• Separation and isolation of data
– Each program maintains its own set of data.
– Users of one program may be unaware of potentially
useful data held by other programs.

• Duplication of data
– Same data is held by different programs.
– Wasted space and potentially different values and/or
different formats for the same item.

www.417solutions.com
Limitations of File-Based
Approach
• Data dependence
– File structure is defined in the program code.

• Incompatible file formats


– Programs are written in different languages, and so
cannot easily access each other’s files.

• Fixed Queries/Proliferation of application


programs
– Programs are written to satisfy particular functions.
– Any new requirement needs a new program.
Database Approach
Database Approach

• Arose because:
– Definition of data was embedded in application
programs, rather than being stored separately
and independently.
– No control over access and manipulation of data
beyond that imposed by application programs.

• Result:
– the database and Database Management
System (DBMS).

www.smppgrisatubdl.com
Database

• Shared collection of logically related data (and a description

of this data), designed to meet the information needs of an

organization.

• System catalog (metadata) provides description of data to

enable program–data independence.

• Logically related data comprises entities, attributes, and

relationships of an organization’s information.


Database
Management System
(DBMS)
• A software system that enables users to define, create,

maintain, and control access to the database.

• (Database) application program: a computer program that

interacts with database by issuing an appropriate request

(SQL statement) to the DBMS.

www.purwadhikapress.com
Database
Management System
(DBMS)
Database Approach

• Data Definition Language (DDL).


– Permits specification of data types, structures and any data
constraints.
– To add, modify, delete Database Object (Table, View, User,
etc)
– Example: CREATE, ALTER, DROP
• Data Manipulation Language (DML).
– General enquiry facility (query language) of the data.
– To add, modify, delete, retrieve record/tuple/row
– Example: INSERT, UPDATE, DELETE, SELECT
• Data Control Language (DML).
– To give or take away privilege(s) to user/role .
– Example: GRANT, REVOKE
Database Approach

• Controlled access to database may include:


– a security system
– an integrity system
– a concurrency control system
– a recovery control system
– a user-accessible catalog.
Views

• Allows each user to have

his or her own view of

the database.

• A view is essentially some

subset of the database.


www.essentialsql.com
Example of View

Student

ClassEnrollment

Join between Student and ClassEnrollment tables to show


StudentNumber, Name, and ClassEnrollment details in
specific Academic Year
Benefits of View

• Reduce complexity

• Provide a level of security

• Provide a mechanism to customize the

appearance of the database

www.bowelcanceraustralia.org
• Present a consistent, unchanging picture

of the structure of the database, even if

the underlying database is changed


Components of DBMS
Environment

• Hardware
– Can range from a PC to a network of computers.
• Software
– DBMS, operating system, network software (if necessary) and
also the application programs.
• Data
– Used by the organization and a description of this data called the
schema.
Components of DBMS
Environment
• Procedures
– Instructions and rules that should be applied to the
design and use of the database and DBMS.
• People

pelajar-sejati.blogspot.com
Roles in the Database
Environment
Roles in the Database
Environment
• Data Administrator (DA)
– is responsible for the management of the data resource
including conceptual/logical database design.
• Database Administrator (DBA)
– is responsible for the physical realization of the database.
• Database Designers (Logical and Physical)
– The logical database designer is concerned with identifying
the data and relationships between the data, and the data
constraints.
– The physical database designer decides how the logical
database design is to be physically realized.
Roles in the Database
Environment
• Application Developers/Programmers
– Implement the application programs that provide the
required functionality for the end-users.
• End Users (naive and sophisticated)
– Naïve users are typically unaware of the DBMS. For
example, the checkout assistant at the local supermarket.
– The sophisticated end-user is familiar with the database
structure and DBMS facilities → may use Structured Query
Language (SQL) to perform the operations or write
application programs.
History of Database
Management Systems
History of Database Systems

• First-generation
– Hierarchical and Network

• Second generation
– Relational

• Third generation
– Object-Relational
– Object-Oriented
Hierarchical Data Model
Network Data Model
Relational Data Model
Terminology of Relational Model
Relational Model Terminology

• A relation is a table with columns and rows.


– Only applies to logical structure of the database, not
the physical structure.
• Attribute is a named column of a relation.
• Domain is the set of allowable values for one
or more attributes.

en.wikipedia.org
Relational Model Terminology

• Tuple is a row of a relation.

• Degree is the number of attributes in a relation.

• Cardinality is the number of tuples in a relation.

• Relational Database is a collection of normalized relations

with distinct relation names.


Instances of Branch and Staff
Relations

Branch Relation/Table
Degree: 4
Cardinality: 5

Staff Relation/Table
Degree: 8
Cardinality: 6
Examples of Attribute Domains
Alternative Terminology
for Relational Model
Mathematical Definition of
Relation

• Consider two sets, D1 & D2, where D1 = {2, 4} and D2 = {1, 3,


5}.
• Cartesian product, D1 X D2, is set of all ordered pairs,
where first element is member of D1 and second element
is member of D2.

D1 X D2 = {(2, 1), (2, 3), (2, 5), (4, 1), (4, 3), (4, 5)}

• Alternative way is to find all combinations of elements


with first from D1 and second from D2.
Mathematical Definition of
Relation

• Any subset of Cartesian product is a relation; e.g.


R = {(2, 1), (4, 1)}
• May specify which pairs are in relation using some
condition for selection; e.g.
– second element is 1:
R = {(x, y) | xD1, y D2, and y = 1}
– first element is always twice the second:
S = {(x, y) | x D1, y D2, and x = 2y}
Mathematical Definition of
Relation

• Consider three sets D1, D2, D3 with Cartesian Product


D1 X D2 X D3; e.g.

D1 = {1, 3} D2 = {2, 4} D3 = {5, 6}


D1 X D2 X D3 = {(1,2,5), (1,2,6), (1,4,5), (1,4,6), (3,2,5),
(3,2,6), (3,4,5), (3,4,6)}

• Any subset of these ordered triples is a relation.


Mathematical Definition of
Relation

• Cartesian product of n sets (D1, D2, . . ., Dn) is:

D1 X D2 X . . . X Dn = {(d1, d2, . . . , dn) | d1 D1, d2 D2, . . . ,


dn Dn}
usually written as:
n
X Di
i=1

• Any set of n-tuples from this Cartesian product is a


relation on the n sets.
Database Relations

• Relation schema
– Named relation defined by a set of attribute and
domain name pairs.

• Relational database schema


– Set of relation schemas, each with a distinct name.
Properties of Relations

• Relation name is distinct from all other relation names in

relational schema.

• Each cell of relation contains exactly one atomic (single)

value.

• Each attribute has a distinct name.

• Values of an attribute are all from the same domain.

• Each tuple is distinct; there are no duplicate tuples.

• Order of attributes has no significance.

• Order of tuples has no significance, theoretically.


Relational Keys

www.cincinnatireview.com

• Superkey
– An attribute, or set of attributes, that uniquely identifies a tuple
within a relation.
– Based on slide slide 40: branchNo, city, postcode are selected as
Superkey of Branch relation

• Candidate Key
– Superkey (K) such that no proper subset is a superkey within the
relation.
– In each tuple of R, values of K uniquely identify that tuple
(uniqueness).
– No proper subset of K has the uniqueness property (irreducibility).
– Based on slide 40, branchNo and postcode are selected as
Candidate Key of Branch relation
Relational Keys

• Primary Key
– Candidate key selected to identify tuples uniquely within relation.
– Based on slide 40: branchNo is primary key of Branch relation,
while staffNo is primary key of Staff relation.

• Alternate Keys
– Candidate keys that are not selected to be primary key.
– Based on slide 40: postcode is Alternate Key of Branch relation

• Foreign Key
– Attribute, or set of attributes, within one relation that matches
candidate key of some (possibly same) relation.
– Based on slide 40, branchNo is foreign key of Staff relation.
Integrity Constraints
Integrity Constraints

• Null
– Represents value for an attribute that is currently unknown
or not applicable for tuple.
– Deals with incomplete or exceptional data.
– Represents the absence of a value and is not the same as
zero or spaces, which are values.

• Entity Integrity
– In a base relation, no attribute of a primary key can be null.
– Based on slide 40: branchNo is primary key of Branch
relation and staffNo is primary key of Staff relation. Both of
them cannot have null value.
Integrity Constraints

•Referential Integrity
– If foreign key exists in a relation, either foreign key value
must match a candidate key value of some tuple in its
home relation or foreign key value must be wholly null.
– Based on slide 40, branchNo is foreign key of Staff
relation. So, its value must refer to branchNo of Branch
relation or null value.

•General Constraints
– Additional rules specified by users or database
administrators that define or constrain some aspect of
the enterprise.
Next Session Preparation

• Read material from Session 2 (Chapter 14) and


watch video [IDS03B-ID] Normalization
www.youtube.com/watch?v=1JKBSOLKbjI&t=43s
• Take notes the main points of materials
• Make sure you understand the materials
SCHOOL OF INFORMATION SYSTEMS
http://sis.binus.ac.id/
http ://www.facebook.com/schoolisbinus

SIS Binus

You might also like