You are on page 1of 50

01/18/2024

DATABASE CONCEPTS

© Manusha Jayarathne 1
What is a Database?
◦ A database is systematically organized storage of information, and it allows easy insertion, updating,
analysis, and retrieval of data.
◦ A collection of interrelated data items that can be processed by one or more application systems.

SLT Rainbow Pages

01/18/2024 Manusha Jayarathne 2


Database Operations
◦ Add Data to the Database.
◦ Read (Search/ Retrieve) Data from the Database.
◦ Update (Change) Existing Data in the Database.
◦ Delete (Remove) Data from the Database.

01/18/2024 Manusha Jayarathne 3


What is Database Management System?
◦ A Database Management System (DBMS) is software designed to store, retrieve, define, and manage
data in a database.
◦ A collection of programs that enables users to store, modify, and extract information from a database
as per the requirements.
◦ MS Access – Simple Database with Single User Access
◦ Oracle – Complex Database with Multiuser Access
◦ Microsoft SQL Server
◦ MySQL
◦ Database Applications
◦ Student Management System
◦ Library Management System
◦ Flight Reservation System

01/18/2024 Manusha Jayarathne 4


01/18/2024 Manusha Jayarathne 5
01/18/2024 Manusha Jayarathne 6
01/18/2024 Manusha Jayarathne 7
Components of a Database?
DBMS

Hardware Software Data Users Procedures

Users with
Management ID, Name, Rules and Regulations Ex: -
RAM, HDD, etc. Different Access
System, etc. Address, etc. (Refund, Unregister)
Levels

◦ Procedures: - Rules that are define and followed by the users.


◦ Liveware: -
◦ Users – Executives, Managers, Staff, etc.
◦ Practitioners – Database Administrators, Analysts, Programmers, Database and System Designers, etc.
01/18/2024 Manusha Jayarathne 8
Computer System Uses Hierarchies
Field Record File Database

◦ Field: - Group of Characters. ( ID / Name / Address / TP etc.)


◦ Record: - Group of related Fields. (ID, Name, Address, TP, etc.)
◦ File: - Group of Records of same type. (Employee Table)
◦ Database: - Group of Related Files. (Company Database)

01/18/2024 Manusha Jayarathne 9


Manual Database vs Computerized
Database

01/18/2024 Manusha Jayarathne 10


Advantages of a DBMS
◦ Minimal Data Redundancy – Separate data files are integrated into single logical structure. Each occurrences of
a data item is recoded only once. ( No Duplicate Data)
◦ Data Consistency – Single occurrence of each data item exists therefore data inconsistencies. (Rules that make
data does not get corrupted or invalid)
◦ Data Shareable – A Database is developed to Share the data among the users who access it.
◦ Easy to Access.
◦ High Data Security – A data administration function is responsible for establishing controls for accessing,
updating and protecting data.

01/18/2024 Manusha Jayarathne 11


Disadvantages of a DBMS
◦ Complexity and Size.
◦ Cost of DBMS & Additional hardware costs.
◦ Performance Problem.
◦ Higher Impact of Failure.

01/18/2024 Manusha Jayarathne 12


Database Architecture
◦ External level –
◦ Interact Directly with Users
◦ Display Data in Familiar Format
◦ This is the Users View of the Database (Restricted Views – Management / Lecturers / Students)
◦ Conceptual Level (Logical Layer) – Describes what data is stored in the database and the relationships (How
data is inter-related) among the data. (Data Model)
◦ Internal Level (Physical Layer) – Interact Directly with the Hardware and Describes how the data is stored in
the database.

01/18/2024 Manusha Jayarathne 13


01/18/2024 Manusha Jayarathne 14
Data Models
◦ Data models describes the relation between different parts of data.
◦ Data models define how the logical structure of a database is modeled.
◦ Data Models are fundamental entities to introduce abstraction in a DBMS.
◦ Data models define how data is connected to each other and how they are processed and stored inside
the system.
◦ Flat Data Model -
◦ Hierarchical Data Model – IBM in 1960
◦ Networking Data Model – Charles Bachman in 1969
◦ Relational Data Model – Edgar Frank Codd (Edgar F. Codd) in 1970

01/18/2024 Manusha Jayarathne 15


Flat Data Model
◦ A flat database is a simple database system in which each database is represented as a single table in
which all the records are stored as single rows of data.

01/18/2024 Manusha Jayarathne 16


Hierarchical Data Model
◦ In hierarchical model, data is organized into a tree like structure with each record is having one parent
record and many children. (One to Many Relationship)
◦ Ex: - Principal -> Section Head -> Class Teacher -> Student (Top To Bottom Order)

01/18/2024 Manusha Jayarathne 17


Networking Data Model
◦ This is an extension of the Hierarchical model. In this model data is organized more like a graph and are
allowed to have more than one parent node. (Many to Many Relationship)
◦ This was the most widely used database model, before Relational Data Model was introduced.

01/18/2024 Manusha Jayarathne 18


01/18/2024 Manusha Jayarathne 19
Relational Data Model
◦ The relational data model describes the world as “a collection of inter-related relations (or tables)”. In
1970 by Edgar F. Codd
◦ Data are organized in a two-dimensional Tables. (Relations)
◦ Tables are Related to each other.

01/18/2024 Manusha Jayarathne 20


01/18/2024 Manusha Jayarathne 21
01/18/2024 Manusha Jayarathne 22
Primary Key!
◦ A primary key is used to uniquely identify all table records. (Ex: - Stu_ID, NIC_No)
◦ A primary key’s main features are:
◦ It must contain a unique value for each row of data.
◦ It cannot contain null values (Empty values).
Student Subject

Marks

01/18/2024 Manusha Jayarathne 23


Foreign Key!
◦ A foreign key is used to create the link between two tables. (Ex: - Student Table and Marks Table)
◦ A Primary key of one table, is the foreign key to another table.
◦ A Foreign key’s features are:
◦ It can contain duplicate data.
◦ It cannot contain null values (Empty values).

01/18/2024 Manusha Jayarathne 24


01/18/2024 Manusha Jayarathne 25
01/18/2024 Manusha Jayarathne 26
Entity-Relationship Model
◦ An Entity–relationship model (ER model) describes the structure of a database with the help of a
diagram, which is known as Entity Relationship Diagram (ER Diagram).
◦ An ER model is a design or blueprint of a database that can later be implemented as a database.
◦ The main components of E-R model are:
◦ Entities and their Attributes
◦ Relationships among Entities

01/18/2024 Manusha Jayarathne 27


Entities
◦ An entity can be place, person, object, event or a concept, which stores data in the database.
◦ Entity name should be in Singular form.
◦ Entities are represented by means of rectangles. Rectangles are named with the entity set they represent.
◦ Ex:- Student , Employee, Course, Teacher, etc.

Student Employee Course Teacher

01/18/2024 Manusha Jayarathne 28


Strong Entity Vs Weak Entity
◦ Strong Entity – Does not depend on another Entity.
◦ Weak Entity – Depend on another Strong Entity.

01/18/2024 Manusha Jayarathne 29


Attributes
◦ Properties or characteristics of an entity known as Attributes.
◦ Attributes describes the entity.
◦ Attributes are the properties of entities. Attributes are represented by means of ellipses. Every ellipse
represents one attribute and is directly connected to its entity.
◦ Ex :- Name, Age, Address can be attributes of the student entity.

Name Age Address

01/18/2024 Manusha Jayarathne 30


◦ Simple Attribute are the attributes that value of the attribute cannot be broken down into component
parts. Ex:- Contact Number
◦ Composite Attribute are the attributes further divided in a tree like structure. Every node is then
connected to its attribute. That is, composite attributes are represented by ellipses that relate to an ellipse.

01/18/2024 Manusha Jayarathne 31


◦ Derived Attributes are the attributes that do not exist in the physical database, but their values are
derived from other attributes present in the database. Derived attributes depicted by dashed ellipse.

01/18/2024 Manusha Jayarathne 32


◦ Single-Value Attribute contain a single value. Ex:- Age
◦ Multi-Value Attribute may contain more than one value. Ex- Qualification (an employee can have
multiple qualifications)

01/18/2024 Manusha Jayarathne 33


◦ Key Attribute is the unique characteristic of the entity. Ex:- Employee ID

◦ Primary Key is a key in a relational database that is unique for each record. It is a unique identifier

01/18/2024 Manusha Jayarathne 34


Ex: - Employee Entity

01/18/2024 Manusha Jayarathne 35


Relationship
◦ Relationship is represented by diamond shape in ER diagram, it shows the relationship among entities.

01/18/2024 Manusha Jayarathne 36


Entity Relationships
◦ A person has an NIC, an NIC belongs to a person

Person Has NIC

01/18/2024 Manusha Jayarathne 37


Degree of a Relationship
◦ Number of Entities in a Relationship.
◦ UNARY - 01 Entity
◦ BINARY - 02 Entities
◦ TERNARY - 03 Entities
◦ N-ARY - More than 03 entities

01/18/2024 Manusha Jayarathne 38


01/18/2024 Manusha Jayarathne 39
01/18/2024 Manusha Jayarathne 40
Cardinality
◦ Number of occurrences in a Relationship.
◦ One to One
◦ ONE person can have maximum ONE NIC, ONE NIC can be belonged to maximum ONE person
◦ One to Many
◦ ONE customer can place MANY orders and MANY orders can be placed by only ONE customer
◦ Many to Many
◦ ONE student can enroll in maximum MANY batches ONE batch can contain maximum MANY students

01/18/2024 Manusha Jayarathne 41


Marking Cardinality

1 M
Father Has Children

01/18/2024 Manusha Jayarathne 42


1 1
Person Has NIC

1 M
Customer Place Order

M Enrolls N
Student Batch
in

01/18/2024 Manusha Jayarathne 43


Maximum Cardinality
◦ Maximum no of entity participation between other entities

◦ One to One

1 1
Person Has NIC

◦ One Person can have maximum One NIC, One NIC can belonged to maximum One person

01/18/2024 Manusha Jayarathne 44


Maximum Cardinality
◦ One to Many

1 M
Mother Have Children

◦ One Mother can have maximum Many Children's, One Child can have maximum One mother

01/18/2024 Manusha Jayarathne 45


Maximum Cardinality
◦ Many to Many

M Enroll N
Student Batch
s in

◦ One Student can enroll in maximum Many Batches, One Batch can contain maximum Many Students.

01/18/2024 Manusha Jayarathne 46


Minimum Cardinality
◦ Minimum No of entity participation in a relationship
◦ Zero is also possible – Optional
◦ At least one is a must - Mandatory

◦ One to One

1..1 0..1
Person Has NIC

◦ One Person can have None or only One NIC, One NIC must be belonged to One and Only One Person.

01/18/2024 Manusha Jayarathne 47


Minimum Cardinality
◦ One to Many

1..1 1..*
Customer Places Order

◦ One Customer must place at least One or Many orders, One Order must be placed by One and Only
One customer.

01/18/2024 Manusha Jayarathne 48


Minimum Cardinality
◦ Many to Many

0..* Enroll 1..*


Student Batch
s in

◦ One Student must enroll in at least One or Many batches, One Batch may contain None or Many
Students at a time.

01/18/2024 Manusha Jayarathne 49


01/18/2024

THANK YOU
Manusha Jayarathne 50

You might also like