Download as pdf or txt
Download as pdf or txt
You are on page 1of 84

Introduction to

Database
Define Database

SLO # 7.1.1
What is Database?
Database refers to a collection of electronic records that could
be processed to produce useful information. The data can be
accessed, modified, managed, controlled and organized to
perform various data-processing operations.

SLO # 1.1.1 Introduction to Computer


Advantage of Database
Management System Over
Traditional File Management
System
SLO # 7.1.2
File Management System Database Management System
• File System is a general, easy-to-use • Database management system is used
system to store general files which when security constraints are high.
require less security and constraints.

• Data Redundancy is more in file • Data Redundancy is less in database


management system. management system.

• Data Inconsistency is more in file • Data Inconsistency is less in database


system. management system.

• Centralization is hard to get when it • Centralization is achieved in Database


comes to File Management System. Management System.
File Management System Database Management System
• User locates the physical address of • In Database Management System,
the files to access data in File user is unaware of physical address
Management System. where data is stored.

• Security is low in File Management • Security is high in Database


System. Management System.

• File Management System stores • Database Management System stores


unstructured data as isolated data structured data which have well
files/entities. defined constraints and interrelation.
Define the role of database
administrator (DBA)

SLO # 7.1.3
Role and Responsibilities of Database
Administrator
✔ Actively participates in planning the installation of new organization-wide
systems and applications. He also assists during the installation as per specific
functions.

✔ Implements the work plan for the Department. He meets the staff to identify
any problems, take measures, and resolves it.

✔ Monitors the efficiency and effectiveness of all database resources and thus,
keep the flow of work uninterrupted.

✔ Ensures maximum service through identification of opportunities for


improvement and make new recommendations.
Role and Responsibilities of Database
Administrator

✔ Continuous review and evaluation of the software, hardware, service delivery,


and updates as and when required.

✔ Maintains a data standard and security measures through the implementation


of information technology plans, policies, and standards.

✔ Troubleshoot the problems[if any]. It includes a quick understanding of the


problem and its resolution, restoration of the data, rectify the issue and
minimize the damage.
Role and Responsibilities of Database
Administrator
✔ Actively attends and participates in the professional group meetings. Thus,
acquire knowledge of the new and upcoming trends and innovations in the IT
field.

✔ Monitor the changes in regulations, technology, and its impact on operations


and implement the new or better ones as required.
Compare the types of models,
i.e. hierarchical database,
network database, relational
database, object oriented
database, object relational
database
SLO # 7.1.4
What is database model?

A database model refers to the logical structure,


representation or layout of a database and how the data will
be stored, managed and processed within it. It helps in
designing a database and serves as blueprint for application
developers and database administrators in creating a
database.
Types of database models
✔ Hierarchical database
✔ Network database
✔ Relational database
✔ Object oriented database
✔ Object relational database
Hierarchical Database
Model

A hierarchical database
model is a data model in
which the data are
organized into a tree-like
structure. The data are
stored as records which are
connected to one another
through links. A record is a
collection of fields, with
each field containing only
one value.
Network Database
Model

A network database
model is a database
model that allows multiple
records to be linked to the
same owner file.
The model can be seen as
an upside down tree where
the branches are the
member information linked
to the owner, which is the
bottom of the tree.
Relational Database
Model
The relational database was
invented in 1970 by E. F.
Codd, then a young
programmer at IBM. In his
paper, "A Relational Model of
Data for Large Shared Data
Banks," Codd proposed
shifting from storing data in
hierarchical or navigational
structures to organizing data in
tables containing rows and
columns.
Object Oriented
Database Model
An object-oriented database is
a database that subscribes to a
model with information
represented by objects.
Object-oriented databases are
a niche offering in the
relational database
management system (RDBMS)
field and are not as successful
or well-known as mainstream
database engines.
An Object relational model is a
combination of a Object oriented
Object database model and a Relational
Relational database model. So, it
supports objects, classes,
Database inheritance etc. just like Object
Oriented models and has support
Model for data types, tabular structures
etc. like Relational data model.
Define structured query
language
(SQL)

SLO # 7.1.5
SQL stands for Structured Query
Language
SQL lets you access and manipulate
Structured databases
Query SQL became a standard of the
American National Standards
Language (SQL) Institute (ANSI) in 1986, and of the
International Organization for
Standardization (ISO) in 1987
✔ SQL can execute queries against a database
✔ SQL can retrieve data from a database
✔ SQL can insert records in a database
✔ SQL can update records in a database
What can SQL ✔ SQL can delete records from a database
✔ SQL can create new databases
do? ✔ SQL can create new tables in a database
✔ SQL can create stored procedures in a
database
✔ SQL can create views in a database
✔ SQL can set permissions on tables,
procedures, and views
Differentiate among the types of
SQL languages, i.e. data definition
language (DDL), data manipulation
language (DML) and data control
language (DCL)

SLO # 7.1.6
SQL statements are categorized into four
Types of SQL different type of statements, which are
Statements ✔ DML (DATA MANIPULATION LANGUAGE)
✔ DDL (DATA DEFINITION LANGUAGE)
✔ DCL (DATA CONTROL LANGUAGE)
✔ TCL (TRANSACTION CONTROL LANGUAGE)
Types of SQL
Statements
The SQL commands that deals with the
manipulation of data present in database belong to
DML or Data Manipulation Language and this
includes most of the SQL statements.

SELECT
Select statement is used to select the collection of records
Data from the table, which is based on some condition.
INSERT
Manipulation Insert statement is used to insert the set of values into
the table.

Language UPDATE
Update statement is used to update the existing values in
the table, which is based on some condition.
DELETE
Delete statement is used to delete the existing record in
the table, which is based on some condition.
DDL or Data Definition Language actually
consists of the SQL commands that can be
used to define the database schema. It simply
deals with descriptions of the database
schema and is used to create and modify the
structure of database objects in database.

Data CREATE
is used to create the database or its objects (like
table, index, function, views, store procedure and
Definition triggers).

Language ALTER
is used to alter the structure of the database.

DROP
is used to delete objects from the database.
DCL includes commands such as GRANT and
REVOKE which mainly deals with the rights,
permissions and other controls of the
database system.

Data GRANT
gives user’s access privileges to database.

Control
Language REVOKE
withdraw user’s access privileges given by using the
GRANT command.
Basic Database
Terminologies
Define the following terms related to relational
database:

a. field/ attribute/ column


b. record/ tuple/ row
c. table
d. file
e. view
f. data type
g. key

SLO # 7.2.1
Database Terminologies

Column (field, attribute)


A column is the smallest unit of storage in a
relational database. A column represents one piece
of information about an object. Every column has a
name and a data type. In Figure 1.1, the shaded
area depicts a single column.

The terms field and attribute have similar Figure 1.1. A column (highlighted).
meanings.
Database Terminologies
Row (record, tuple)

A row is a collection of column values. Every row


in a table has the same shape (in other words,
every row is composed of the same set of
columns). In Figure 1.2, the shaded area depicts a
row.

The terms record or tuple are equivalent to a


row. Figure 1.2. A row (highlighted).
Database Terminologies
Table (relation, file)
A table is a collection of rows. A table usually has a name, although some tables are
temporary and exist only to carry out a command. All the rows in a table have the
same shape (in other words, every row in a table contains the same set of columns). In
other database systems. The terms relation and file are all equivalent to a table.

View
A view is an alternative way to present a table (or tables). You might think of a view as a
"virtual" table. A view is (usually) defined in terms of one or more tables. When you
create a view, you are not storing more data, you are instead creating a different way of
looking at existing data. A view is a useful way to give a name to a complex query that you
may have to use repeatedly.
Database Terminologies
Data type
Data types define what type of data a column can contain.

Key
A DBMS key is an attribute or set of an attribute which helps you to identify a row(tuple)
in a relation(table). They allow you to find the relation between two tables. Keys help you
uniquely identify a row in a table by a combination of one or more columns in that table.
Define the data types available in a
relational database; i.e. character,
integer, real number, Boolean data,
date and time;

SLO # 7.2.2
Data types in relational database
Character
Character data types to deal with printable and displayable characters. Char holds a
single character whereas String contains an indefinite number of characters.

Integer
Integer data types hold numbers that are whole, or without a decimal point.

Example
234 45678 1 67
Data types in relational database
Real number
These data types have a precision, or a positive integer that defines the number of
significant digits. This type of data representation is commonly called floating-point
representation.

Example
2.2 34.56 1.1

Boolean data

The Boolean data type is a data type that has one of two possible values (usually
denoted true and false).
Data types in relational database
Date and time
The DATETIME type is used for values that contain both date and time parts.
Differentiate among primary key,
candidate key, alternate key,
secondary key, foreign key;

SLO # 7.2.3
Keys in relational database
What is a Primary Key?
A column or group of columns in a table which helps us to uniquely identifies every
row in that table is called a primary key. This DBMS can't be a duplicate. The same
value can't appear more than once in the table.

Rules for defining Primary key:

✔ Two rows can't have the same primary key value


✔ It must for every row to have a primary key value.
✔ The primary key field cannot be null.
✔ The value in a primary key column can never be modified or updated if any foreign
key refers to that primary key.
Keys in relational database
What is a Candidate Key?
A super key with no repeated attribute is called candidate key.

Rules for defining Candidate key:

✔ It must contain unique values


✔ Candidate key may have multiple attributes
✔ Must not contain null values
✔ It should contain minimum fields to ensure uniqueness
✔ Uniquely identify each record in a table
Keys in relational database
What is a Alternate Key?
All the keys which are not primary key are called an alternate key. It is a candidate key
which is currently not the primary key. However, A table may have single or multiple
choices for the primary key.
Keys in relational database
What is a Secondary key?
An entity may have one or more choices for the primary key. Collectively these are
known as candidate keys. One is selected as the primary key. Those not selected are
known as secondary keys.
Keys in relational database
What is a Foreign Key?
A foreign key is a column which is added to create a relationship with another table.
Foreign keys help us to maintain data integrity and also allows navigation between two
different instances of an entity. Every relationship in the model needs to be supported
by a foreign key. This concept is also known as Referential Integrity.
Difference between primary and foreign key

Primary Key Foreign Key


• Helps you to uniquely identify a • It is a field in the table that is the
record in the table. primary key of another table.
• Primary Key never accept null values. • A foreign key may accept multiple null
• You can have the single Primary key in values.
a table. • You can have multiple foreign keys in a
table.
Planning a Database
Explain the following steps for designing
database:

a. Problem identification/ definition


b. Feasibility study
c. Requirement Analysis
d. Identifying entities and attributes
e. Assigning names to tables and columns

SLO # 7.3.1
Planning a Database

Problem identification/ definition

The first step in the problem solving and decision making process is to identify and
define the problem.

A problem can be regarded as a difference between the actual situation and the
desired situation. This means that in order to identify a problem the team must
know where it is meant to be and have a clear understanding of where it currently
is in relation to the perceived problem.
Planning a Database
Feasibility study

Feasibility is defined as the practical extent to which a project can be performed


successfully.

A feasibility study is performed, which determines whether the solution considered


to accomplish the requirements is practical and workable in the database.

Information such as resource availability, cost estimation for database, benefits of


the database to the organization after it is developed and cost to be incurred on its
maintenance are considered during the feasibility study.
Planning a Database
Requirements Analysis

Requirements Analysis is the process of determining what the database is to be


used for.

It involves interviews with user groups and other stakeholders to identify what
functionality they require from the database, what kinds of data they wish to
process and the most frequently performed operations.

This discussion is at a non-technical level and enables the database designers to


understand the business logic behind the desired database.
Planning a Database
Identifying entities and attributes

Entities
An Entity may be an object with a physical existence – a particular person, car,
house, or employee – or it may be an object with a conceptual existence – a
company, a job, or a university course.

Attributes
Attributes are the properties which define the entity type. For example, Roll_No,
Name, DOB, Age, Address, Mobile_No are the attributes which defines entity type
Student.
Data Modeling
Explain the process of data modeling

SLO # 7.4.1
What is Data Modelling?
Data modeling is the process of creating a data model for the data to be
stored in a Database. This data model is a conceptual representation of
:
• Data objects
• The associations between different data objects
• The rules

Data model emphasizes on what data is needed and how it should be


organized. Data Model is like architect's building plan which helps to
build a conceptual model and set the relationship between data items.
What is Data Modelling?
Types of data models

The two types of Data Models techniques are


1. Entity Relationship (E-R) Model
2. UML (Unified Modelling Language)
Discuss the Entity Relationship Diagram (ERD)
and its components i.e. Entity relationship,
degree of relationship (cardinality) and
attributes;

SLO # 7.4.2
What is ER Diagrams?

Entity relationship diagram displays the relationships of entity set


stored in a database. In other words, we can say that ER diagrams help
you to explain the logical structure of databases. At first look, an ER
diagram looks very similar to the flowchart. However, ER Diagram
includes many specialized symbols, and its meanings make this model
unique.
Example of ER Diagrams
What is ER Diagrams?

Entity relationship diagram displays the relationships of entity set


stored in a database. In other words, we can say that ER diagrams help
you to explain the logical structure of databases. At first look, an ER
diagram looks very similar to the flowchart. However, ER Diagram
includes many specialized symbols, and its meanings make this model
unique.
Facts about ER Diagram Model:

• ER model allows you to draw Database Design


• It is an easy to use graphical tool for modeling data
• Widely used in Database Design
• It is a GUI representation of the logical structure of a Database
• It helps you to identifies the entities which exist in a system and the
relationships between those entities
Components of the ER Diagram:

This model is based on three basic concepts:

• Entities
• Attributes
• Relationships
Example
For example, in a University database, we might have entities for Students, Courses,
and Lecturers. Students entity can have attributes like Rollno, Name, and DeptID.
They might have relationships with Courses and Lecturers.
What is Entity?
An entity can be place, person, object, event or a concept, which stores
data in the database. The characteristics of entities are must have an
attribute, and a unique key. Every entity is made up of some 'attributes'
which represent that entity.

Examples of entities: Notation of an Entity


Person: Employee, Student, Patient
Place: Store, Building
Object: Machine, product, and Car
Event: Sale, Registration, Renewal
Concept: Account, Course
What are Attributes?
It is a single-valued property of
either an entity-type or a
relationship-type.
For example, a lecture might
have attributes: time, date,
duration, place, etc.

An attribute is represented by an
Ellipse.
What are Relationship?
Relationship is nothing but an association among two or more entities. E.g.,
Tom works in the Chemistry department.

Entities take part in relationships. We can often identify relationships with


verbs or verb phrases.
What are Cardinality?

Defines the numerical attributes of


the relationship between two entities
or entity sets.

Different types of cardinal


relationships are:
• One-to-One Relationships
• One-to-Many Relationships
• May to One Relationships
• Many-to-Many Relationships
Cardinality Notations
Show different types of relationships between
two entities;

SLO # 7.4.3
One to One
One entity from entity set X can be associated with at most one entity of
entity set Y and vice versa.

Example: One student can register for numerous courses. However, all those
courses have a single line back to that one student.
One to Many
One entity from entity set X can be associated with multiple entities of entity
set Y, but an entity from entity set Y can be associated with at least one
entity.

For example, one class is consisting of multiple students.


Many to One
More than one entity from entity set X can be associated with at most one
entity of entity set Y. However, an entity from entity set Y may or may not be
associated with more than one entity from entity set X.

For example, many students belong to the same class.


Many to Many
One entity from X can be associated with more than one entity from Y and
vice versa.

For example, Students as a group are associated with multiple faculty


members, and faculty members can be associated with multiple students.
Illustrate the difference between
cardinality and modality

SLO # 7.4.4
What are Cardinality?

Defines the numerical attributes of


the relationship between two entities
or entity sets.

Different types of cardinal


relationships are:
• One-to-One Relationships
• One-to-Many Relationships
• May to One Relationships
• Many-to-Many Relationships
What are Modality?
The Modality is completely different from the cardinality. Its value is computed
as “o” when there is no requirement for the relationship to occur or if the
relationship is optional. The modality value is “1” if there is a compulsion for
the occurrence of a relationship. In simple words, it describes whether a
relationship between two or more entities is even required or not.
Draw entity relationship diagram for different
scenarios;

SLO # 7.4.5
Describe the normalization of relational
database;

SLO # 7.4.6
What is Normalization?

Normalization is a database design technique which organizes tables in


a manner that reduces redundancy and dependency of data.

It divides larger tables to smaller tables and links them using


relationships.

You might also like