0% found this document useful (0 votes)
18 views118 pages

Ss3 Data Processing 1st Term Final Handout

Uploaded by

oforjose3.0
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)
18 views118 pages

Ss3 Data Processing 1st Term Final Handout

Uploaded by

oforjose3.0
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/ 118

DATA PROCESSING

SS3… First Term

1
NORMALIZATION
THEORY
• At the end of this lesson, students should be able to
i) Define normalization;
ii) State the goals of Normalization;
iii) Mention the three anomalies in databases.

2
NORMALIZATION
• What is Normalization?
• Normalization is the process of efficiently organizing data in a database.

• There are two goals of the normalization process:


a. Minimize data redundancy (for example, storing the same data in
more than one table ) and
b. ensuring data dependencies make sense (only storing related data
in a table).

• By breaking down a large, complex table


into smaller, related tables and linking
them through relationships, normalization • Objectives:
helps improve database performance and i) Define normalization;
reduce database anomalies.
ii) State the goals of
Normalization;

iii) Mention the three 3


anomalies in databases.
NORMALISATION
• Normalisation theory deals with reducing undesirable properties such as
redundancy, INSERT anomaly, DELETE anomaly, UPDATE anomaly.

LET’S USE THE TWO TABLES BELOW TO EXPLAIN THE 3 ANOMALIES


T1

T2

• Objectives:

i) Define normalization;

ii) State the goals of


Normalization;

iii) Mention the three 4


anomalies in databases.
INSERT ANOMALY

• We can’t insert a new sales office called Atlanta


until we know the Sales Person.
• We can’t do this because we must have a
primary key which is EmployeeID in the table.
• Objectives:

i) Define normalization;

ii) State the goals of Normalization;

iii) Mention the three anomalies in


databases.
• Insert anomaly: Until the new
faculty member, Mr. Gege is
assigned to teach at least one • Objectives:
course, his details cannot be i) Define normalization;
created in the database.
ii) State the goals of
Normalization;

iii) Mention the three 6


anomalies in databases.
UPDATE ANOMALY

• There will be inconsistency if modification to a data is not


done on all rows where such data exists.
• Objectives:

i) Define normalization;

ii) State the goals of


Normalization;

iii) Mention the three 7


anomalies in databases.
2ND EXAMPLE

• An update anomaly. Employee 519 is shown as having


different addresses on different records.

8
DELETE ANOMALY

• If a sales person retires, deleting his name will remove other


data such as the sales office and customers.
• Objectives:

i) Define normalization;

ii) State the goals of Normalization;

iii) Mention the three anomalies in


databases.

9
• Delete anomaly. All information about Dr. Giddens is lost if
he temporarily ceases to be assigned to any course.
• Objectives:

i) Define normalization;

ii) State the goals of


Normalization;

iii) Mention the three 10


anomalies in databases.
SUMMARY
• INSERT ANOMALY: This refers to the situation when it is
impossible to insert certain types of data into the database due to
the absence of key fields.
• DELETE ANOMALY: The deletion of data leads to unintended
loss of additional data (data we wish to preserve).
• UPDATE ANOMALY: This refers to the situation where updating
the value of a column leads to database inconsistencies (i.e.
different rows on the table have different values).

• Objectives:

i) Define normalization;

ii) State the goals of


Normalization;

iii) Mention the three 11


anomalies in databases.
NEXT
• Class Activity

12
ACTIVITY…. 2 MINUTES.
1. What do you call the process of reducing undesirable
properties in a database?
2. Storing the same data in more than one table is technically
termed data ___________
3. A situation where modifying the value of a field leads to
database inconsistency is termed _________
4. A situation when it is impossible to add certain types of
data to the database is termed ____ anomaly
5. If the removal of data leads to unintended loss of
additional data, then we have ________ anomaly

13
SEE THIRD TERM Q BANK

The database design prevents some data from being stored due
to

A) Deletion anomalies
B) Insertion anomalies
C) Update anomalies
D) Selection anomalies

14
NORMAL FORMS

• At the end of this lesson students should be able to


i) Define normal forms;
ii) Enumerate examples of normal forms
iii) Decompose tables to at least the 1NF.

15
NORMAL FORMS
• Normal Form (NF) is a set of rules or guidelines used to
structure and organize the data within database tables to
minimize data redundancy, improve data integrity, and reduce
database anomalies.
The normal forms are:
1NF - First Normal Form
2NF - Second Normal Form
3NF - Third Normal Form
BCNF - Boyce-Codd Normal Form i) Define normal forms;
5NF - Fifth Normal Form ii) Enumerate examples
of normal forms
iii) Decompose tables to
at least the 1NF.
FIRST NORMAL FORM (1NF)
1. Every field in 1NF must be atomic, that is, indivisible. In other words, there must be no “multi-valued”
field

2. Every record must be unique (i.e. have a primary key)


3. There should be no repeating columns like vehicle1, vehicle2, vehicle3…
https://www.youtube.com/watch?v=jgUeOjImOOw&feature=youtu.be

T1

i) Define normal forms;


ii) Enumerate examples of normal forms
17

iii) Decompose tables to at least the 1NF.


1NF EXAMPLE

Id Name Age Interests


1 John 14 Soccer, Programming
2 Garba 15
3 Daniel 13 Music

SOLUTION
I Name Age Interests
i) Define normal forms; d

ii) Enumerate examples 1 John 14 Soccer


1 John 14 Programming
of normal forms
2 Garba 15
iii) Decompose tables to 3 Daniel 13 Music 18

at least the 1NF.


MENTION THE THREE MOST
WIDELY USED NORMAL FORMS

i) Define normal forms;


ii) Enumerate examples
of normal forms
iii) Decompose tables 19 to

at least the 1NF.


EXAMPLE: ORDER TABLE (T3)
Item Colour Price Tax
T-shirt Red, blue 12.00 0.60
Polo Red, yellow 12.00 0.60
Sweatshirt Blue, black 25.00 1.25

The table is not in first normal form. Why?


1. Multi-valued fields.
2. No primary key.

i) Define normal forms;


ii) Enumerate examples
of normal forms
20
iii) Decompose tables to
at least the 1NF.
RESOLVED: ORDER TABLE (T4)
Item Colour Price Tax
T-shirt Red 12.00 0.60
T-shirt Blue 12.00 0.60
Polo Red 12.00 0.60
Polo Yellow 12.00 0.60
Sweatshirt Blue 25.00 1.25
Sweatshirt Black 25.00 1.25
• Resolve the multi-values. i) Define normal forms;
• Concatenate two fields to form ii) Enumerate examples
composite key or concatenated of normal forms
primary key.
iii) Decompose tables to
• We now have the table in 1NF at least the 1NF.
SECOND NORMAL FORM
1. The table must FIRST be in 1NF
2. All non-key fields must depend on all components of the
primary key.
T4

Item Colour Price Tax


T-shirt Red 12.00 0.60
T-shirt Blue 12.00 0.60
Polo Red 12.00 0.60
Polo Yellow 12.00 0.60
Sweatshirt Blue 25.00 1.25
Sweatshirt Black 25.00 1.25

 In
table T4, Price depends on item but not 22

on colour.
THE TABLES IN
2NF
T5
T6
Item Colour
T-shirt Red Item Price Tax
T-shirt Blue T-shirt 12.00 0.60
Polo Red Polo 12.00 0.60
Polo Yellow Sweat 25.00 1.25
shirt
Sweatshirt Blue
Sweatshirt black

23
3NF
• The table must FIRT be in 2NF
• No non-key field depends upon another. All non-
key fields must depend ONLY on the primary key.
• Table T6 below is not in 3NF…. Why?

T5 T6
Item Price Tax
Item Colour
T-shirt 12:00 0.60
T-shirt Red
T-shirt Blue Polo 12:00 0.60
Polo Red Sweatshirt 25:00 1.25
Polo Yellow i) Define normal forms;
Sweatshirt Blue
ii) Enumerate examples
Sweatshirt black
of normal forms
iii) Decompose tables to
at least the 1NF.
TABLES IN 3NF
T5

Item Colour Item Price T7

T-shirt Red T-shirt 12.00


T-shirt Blue Polo 12.00
Polo Red Sweats 25.00
Polo Yellow hirt
T8
Sweatshirt Blue
Price Tax
Sweatshirt black
i) Define normal forms;
12.00 0.60
ii) Enumerate examples of normal 25.00 1.25
forms
25
iii) Decompose tables to at least the
1NF.
ASSIGNMENT ACTIVITY
State as vivid as possible, the two rules for each of the
following:
a. 1NF
b. 2NF
c. 3NF

i) Define normal forms;


ii) Enumerate examples
of normal forms
26
iii) Decompose tables to
at least the 1NF.
SOLUTION
1NF
1. No repeating elements or group of elements
2. Every record must be unique

2NF
1. Must be in 1NF
2. No partial dependencies on a composite key
i) Define normal forms;
3NF ii) Enumerate examples
1. Must be in 2NF of normal forms
27
2. No dependencies on non-key attributes iii) Decompose tables to
at least the 1NF.
EXTRA WORK

• Is the table above in 1NF or not?


• If not, mention what is wrong with the table.

i) Define normal forms;


ii) Enumerate examples
of normal forms
28
iii) Decompose tables to
at least the 1NF.
Extra work
RESOLVE TO 1NF
Dept Knowledge First Last
name name
iOS Java, C++, Thomas Mueller
iOS PHP, Java Ursula Meier
Andr C++, Java Igor Mueller
oid

Solution
Dept Knowledge First name Last
i) Define normal forms;
name
iOS Java Thomas Mueller ii) Enumerate examples
iOS C++ Thomas Mueller of normal forms
iOS PHP Ursula Meier iii) Decompose tables to
iOS Java Ursula Meier at least the 1NF.
Android C++ Igor Mueller 29

Android Java Igor Mueller


EXTRA WORK

• Determine whether the table is in 1NF

i) Define normal forms;


ii) Enumerate examples
of normal forms
30
iii) Decompose tables to
at least the 1NF.
EXTRA WORK
• Determine if the table below is in 1NF. Explain your answer.

31
CLASS WORK
1. With the aid of a table vividly explain composite
key?
2. Normalise the table below to 1NF and 2NF.
Item Colour Price Tax

Huawei White, Yellow 16.00 0.50


PSmart

Iphone Yellow, blue 19.00 0.70

Galaxy Blue, Red 17.00 0.25

32
SOLUTION

i) Define normal forms;


ii) Enumerate examples
of normal forms
33
iii) Decompose tables to
at least the 1NF.
RESOLVED 1NF
Item Colour Price Tax
Huawei White 16.00 0.50
PSmart
Huawei Yellow 16.00 0.50
PSmart
iphone Yellow 19.00 0.70
iphone blue 19.00 0.70
Galaxy Blue 17.00 0.25
Galaxy Red 17.00 0.25

i) Define normal forms;


ii) Enumerate examples of normal forms
34
iii) Decompose tables to at least the 1NF.
RESOLVED TO 2NF
Item Colour
Item Price Tax
Huawei PSmart White
Huawei 16.00 0.50
Huawei PSmart Yellow
PSmart
iphone Yellow
iphone 19.00 0.70
iphone blue
Galaxy 17.00 0.25
Galaxy Blue
Galaxy Red
i) Define normal forms;
ii) Enumerate examples of
normal forms
iii) Decompose tables to at least
35
the 1NF.
SAMPLE QUESTIONS
1. An attribute or a set of attributes of one table that is
matched to candidate keys of another is called ____ key
2. The primary key that is made up of two or more attributes is
called _________ key
3. The other keys that qualify as primary keys but are not
selected as the primary keys are termed __________
4. Mention the most suitable attribute to be used as primary
key in a bank database

36
SOLUTION

Answers
1. Foreign key
2. Composite key
3. Candidate key
4. Account number

37
PROGRAMMING TIPS

What are Programming Languages:


• They are the programs used for writing other programs.
• Python
• Java
• C++
• C#

38
Q) THE PROCESS OF EFFICIENTLY
ORGANIZING DATA IN A
DATABASE IS…

Normalization
Redundancy
Rationalization

39
DATABASE INDEXES
• At the end of this lesson students should be able to
i) Describe database index;
ii) State the advantages of database index;
iii) Enumerate and explain the various types of indexes;
iv) Create database index using MS Access.

40
DATABASE
INDEXES
 See the index at the end of a
book.
 Why would you use a book
index?
 Why do you need Database
indexes.
 Indexes make it faster to
find specific records in a
database.

41
DATABASE INDEXING
What is DATABASE INDEX? i) Describe database index;
ii) State the advantages of
• A database index is a list of keys (or
database index;
keywords), each of which identifies a
iii) Enumerate and explain the
unique record. various types of indexes;
• Index File: an index file is a table with two iv) Create database index
columns: one stores a sorted list of the using MS Access.
values in the field being indexed and the
second stores pointers that give the location
of each record in the table.
• That is, an index is a file which consists of
records (called index entries) of the form…

42
search key value pointer to block in data file
CLASS ACTIVITY

1. What is a database index?


2. What is an index file?
3. Sketch the structure of index file
4. How is automatic indexing done by the database engine?

43
INDEX FILE

44
TYPES OF INDEX
1. Primary Index: Primary index is defined on an ordered
data file. The data file is ordered on a key field. The key
field is generally the primary key of the relation. E.g.
Employee ID or RegNo as in the table below.

45
2. Secondary (Non-clustering) index : An index that is defined on
a non-ordering field of the data file.

A Secondary index may be generated from a field which is a


candidate key and has a unique value in every record, or a
non-key with duplicate values.

That is, indexing is done on a set of attributes different from the


primary key

46
ASSIGNMENT

• Source: The recommended textbook.


• State the differences between the following types of index
a. Clustered versus non-clustered index
b. Dense versus sparse index

47
CREATING A SINGLE-FIELD
INDEX IN MS ACCESS
• In the Navigation Pane, right-click the name of the table that
you want to create the index in, and then click Design View on
the shortcut menu.
• Click the Field Name for the field that you want to index.
• Under Field Properties, click the General tab.
• In the Indexed property, click Yes (Duplicates OK) if you want
to allow duplicates, or Yes (No Duplicates) to create a unique
index.
• To save your changes, click Save

48
MS ACCESS PRACTICAL

49
BASIC SQL

• At the end of this lesson, students should be able to


i) Describe SQL;
ii) State the uses of SQL in databases;
iii) Create tables with SQL and insert data into tables;
iv) Select data from given tables in the database.

50
WHAT IS SQL
• SQL stands for Structured Query Language.
• It is the standard scripting language for manipulating
databases and their objects.
• Created by Donald D. Chamberlin and Raymond F. Boyce in the
1970s.

51
WHAT CAN YOU DO WITH SQL?

With SQL you can


1. Create databases
2. Create tables
3. Add data to tables
4. Retrieve data from tables
5. Modify content of database tables
6. Drop database/tables

52
CREATE TABLES
• Using SQL
Open Access
Create a database
Name it Your name-Current date

To enable the SQL environment in Access:-


1. Click on Create tab
2. Click on Query Design
3. Close the dialog box • At the end of this lesson, students should be able to

i) Describe SQL;
4. Click on SQL
ii) State the uses of SQL in databases;

iii) Create tables with SQL and insert data into 53


tables;

iv) Select data from given tables in the database.


CREATE TABLE StudentData
(AdmNum Text Primary Key,
FirstName VarChar(15) NOT NULL,
LastName VarChar(15) NOT NULL,
Gender Char(1),
Class Text,
DOB DateTime)

Click the Run button to execute the query.


Find out the difference between VarChar and
Char.
• At the end of this lesson, students should be
able to
i) Describe SQL;
ii) State the uses of SQL in databases;
iii) Create tables with SQL and insert data 54
into tables;
iv) Select data from given tables in the
database.
CLASS ACTIVITY
Create the table below
using only SQL (5 marks)
Name Class Score

Table name: SURNAMEActivity • At the end of this lesson, students should be


able to
Define the fields as follows: i) Describe SQL;
ii) State the uses of SQL in databases;
iii) Create tables with SQL and insert data
Name: VarChar(50) into tables;
Class: Char(4) iv) Select data from given tables in the
Score: INT database.
Add a primary key of your choice.
Your next task is to insert data of your choice into
the fields using SQL (5 marks) . To do this, 55
carefully study the next topic.
INSERTING VALUES INTO
EXISTING TABLE
• The general format:
INSERT INTO TableName
VALUES (values separated by commas)

NB: You need to refresh the table using the F5 function key to
see the values you inserted OR Close the table and reopen
it.

• At the end of this lesson, students should be


able to
i) Describe SQL;
ii) State the uses of SQL in databases;
iii) Create tables with SQL and insert data
56
into tables;
iv) Select data from given tables in the
database.
EXAMPLE
1. Create the table below using SQL
2. Insert the record “001”,’Dapo’, ‘SS3A’ into a table called
manifest as shown below
Id StName Class

INSERT INTO manifest


VALUES (“001”,‘Dapo’, ‘SS 3A’);

• At the end of this lesson, students should be


Add the following: able to
i) Describe SQL;
002,”Dipo”,”SS 3B” ii) State the uses of SQL in databases;
iii) Create tables with SQL and insert data
003,”Femi”,”SS 3C” into tables;
iv) Select data from given tables in the
database.
004,”Chukwudi”,”SS 3A” 57
EXTRACTING DATA FROM TABLES
• You can extract data from database table(s) using the SELECT
keyword.
• The result is stored in a result table, called the result-set.
• SELECT Field1,Field2,…
FROM TableName; Manifest
Id StName Class
• E.g. To extract all the data
• SELECT * FROM Manifest
• What is the result of the following query?
• At the end of this lesson, students should be
• SELECT StName FROM Manifest able to
i) Describe SQL;
ii) State the uses of SQL in databases;
iii) Create tables with SQL and insert data
into tables;
iv) Select data from given tables in the
database.
SELECT COMMAND
Try out the following SQL code
• SELECT CustomerName, State FROM Customers;
• SELECT * FROM Customers;

• At the end of this lesson, students should be


able to
i) Describe SQL;
ii) State the uses of SQL in databases;
iii) Create tables with SQL and insert data
into tables; 59
iv) Select data from given tables in the
database.
SELECT …. WHERE
General Form:
SELECT Column1, column2 FROM TableName … WHERE
Fieldname = “x”
Example:-
• SELECT CustomerName FROM Customer WHERE State =
“Lagos”;
Try out:-
• SELECT CustomerName FROM Customer WHERE Country =
“Nigeria”;

60
SQL PROJECT. FOLLOW THE INSTRUCTION
CAREFULLY.
1) Create a database using your Surname & First name as the database name.

2) Create the table below (Customer) using SQL. Save the SQL as Qtable.

3) Insert the values in the given table into your table using SQL. Save this SQL as QInsertData. Note: You must
change the customer’s names to any names of your choice.

4) Using SQL, extract all the CustomerName, Phone and State. Save this SQL as QExtractData.

CustomerID CustomerName Phone State

5) Save your work and close the database.


6) Navigate to your database in Document folder, copy it in a flash and submit for grading on
or before Tuesday 1st October. 61
7) Check that your file is properly copied. DO NOT SUBMIT SHORTCUT.
Also note that the project must be the only file in the flash you are using to submit this work.
DROP

• Drop deletes an object.


• E.g. to delete a table, issue the command
• DROP TABLE tablename;

62
PRACTICAL TEST

• Next slide

63
WRITE THE SQL CODE TO
CREATE THE TABLE BELOW
Use the following info for
each data: PhoneList
ID
ID (INT and primary key) Surname
Surname (VarChar)
First_Name (VarChar) First_Name
Phone (Text) Phone
State (Text)
State
• Save the database as your name and date.
• Insert the records below into the table created using sql
code:
• 1, Goodluck, Femi, 08069847638, Ogun 64

• 2, Gbajabiamila, Kukere, 07054542343, Lagos


EXTRA TASK (C)
Num Name Class Score
212 Femi SS 2 18
213 Daniel SS 3 19
214 John SS 2 17
215 Matthew SS 2 16

• Write the SQL that creates the table ScoreData above


with Num as alphanumeric and primary key, Name is
alphanumeric with 55 maximum characters. Class is
alphanumeric with 4 maximum characters; and Score is
integer. All the fields are mandatory.
65
ACTIVITY
• Write query that extracts the Name and Age of Jane from the table
above if the table name is passenger.

66
ADDING COLUMN TO TABLE

To add a column to the table use:

ALTER TABLE TableName ADD[ColumnName]

Example:

ALTER TABLE abc ADD [AdmNo] INT

67
ALTER A RECORD
• The UPDATE keyword is used for altering the content of a record
• To alter the stname and AdmNo in row 1:
UPDATE abc SET Stname='Fred', ADMNO =5454 WHERE
Stname='Felix';

• You get the result in the table below.

68
CREATE THE TABLES BELOW USING
SQL
DATABASE NAME: EMPLOYEE
Employee
Company
EmpId
Name
FirstName
Address
LastName
City
Address
Phone
Phone
State
Company
HireDate
City 69

JobTitle
SOME TASKS

70
CREATE THE TABLE BELOW USING
SQL. DATABASE NAME IS
STUDENTDB. TABLE NAME IS
STSCORE
ExamNum FirstName LastName Score

NOTE:- MAKE EXAMNUM THE PRIMARY KEY


71
CREATE THE TWO TABLES BELOW
USING SQL. ADD 10 RECORDS. SAVE
AND ZIP YOUR DATABASE. SEND THE
ZIPPED DATABASE TO ME ON
EDUPAGE.
Employees
First name
Last name Company
Address Name
Zip Address
Phone City
Company Zip
Hire_date Phone
Picture State
City
72
Deadline:
Job_title
Salary
IN YOUR NOTE, WRITE THE SQL CODE
FOR CREATING THE TABLE BELOW.
TABLE NAME IS “PRODUCT”. SERIAL
NO IS PRIMARY KEY

Serial _no Product Price Date_delivered

Serial_no is alphanumeric, Product is alphanumeric with 25


maximum characters. You should deduce the data type of the
remaining fields. All the fields are mandatory.

73
SOLUTION
CREATE TABLE Product(Serial_no INT Primary Key,
Product VarChar(10) NOT NULL,
Price Currency,
Date_delivered DateTime);

OR
CREATE TABLE Product(Serial_no INT Primary Key,
Product VarChar(10) NOT NULL,
Price Money,
Date_delivered DateTime);

74
Fill in the missing commands in the SQL code

______ StudentData(StdID INT Primary key)

Answer:
CREATE TABLE StudentData(StdID INT Primary key)

75
MANUALLY CREATE THE TABLE
BELOW
Customer CustomerNa Phone State Countr
ID me y
Cust_1 Garba 090746346 Borno Nigeria
2
Cust_2 Brown 276173827 Londo Uk
8 n
Cust_3 Jersey 984938234 Ashant Ghana
2 i
Cust_4 Dele 080273627 Lagos Nigeria
3

Database name: Your name-date

Table name: Customers 76


INTRODUCTION TO PHPMYSQL

• Run WAMP or XAMP


• Run localhost
• Create database
• Create tables

77
DATABASE SECURITY

At the end of this topic students should


be able to
1) Define database security;
2) State various ways of securing a
database.
78
DATABASE SECURITY
• Definition: Database security can be described as the level of
control or restriction on user actions on the database. This
control includes access to data, database server and its
applications.

• It is the protection of data against unauthorized access,


disclosure, alteration or destruction.

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security; 79

2) State various ways of securing a


database.
SECURITY RISKS TO
DATABASE SYSTEMS
• This includes:
1. Unauthorised activity, e.g. a hacker.
2. Misuse by authorised users.
3. Malware infection which deletes, damages or makes sensitive data
available.
4. Overloads which can lead to inability of authorised users to use the
database.
5. Physical damage to servers, e.g. fire, flood, lightning, accidental liquid
spills, electrical surge, etc.

Topic: Database Security


At the end of this topic students should be able to
1) Define database security; 80
2) State various ways of securing a database.
6. Design flaws and programming bugs which create
security vulnerabilities.
7. Data corruption or loss caused by the entry of invalid
data or commands, mistakes in database or system
administration processes, sabotage or criminal damage.

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security; 81

2) State various ways of securing a


database.
IMPORTANCE OF DATA
SECURITY

There are three main objectives to consider while designing a


secure database application:
1. secrecy
2. integrity and
3. availability

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security; 82

2) State various ways of securing a


database.
1. SECRECY

a) Secrecy denotes the protection of information from


unauthorized disclosure either by direct retrieval or by
indirect logical inference.
b) Secrecy must deal with the possibility that information may
also be disclosed by legitimate users by passing secret
information to unauthorized users intentionally or without
knowledge of the authorized user.

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security; 83

2) State various ways of securing a


database.
2. INTEGRITY

• Integrity constraints are rules that define the correct states of a


database.
• Integrity entails data protection from malicious or accidental
modification, including the insertion of false data,
contamination and the destruction of data.
• Read up: SQL injection

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security; 84

2) State various ways of securing a


database.
3. AVAILABILITY
• Availability is the characteristic that ensures data is
accessible by authorized users and database applications
when they need them.

85
TYPES OF DATABASE SECURITY
CONTROL
• Many layers and types of information security control are
appropriate to databases, including:
• Access control
• Database Auditing
• Authentication
• Encryption
• Integrity controls
• Backups
• Application security Topic: Database Security
At the end of this topic students should
be able to
1) Define database security; 86

2) State various ways of securing a


database.
ACCESS CONTROL
• This is the selective restriction of access to a resource in the
database. It is a system of controlling data that is accessible to
a given user.
• Permission to access a resource is termed authorisation.
• Access control can be mandatory or discretionary

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security;
2) State various ways of securing a 87

database.
DAC
• Users have privileges to access or modify objects in the database. If
they have permission, users can grant their privileges to other users.
• Allows an individual complete control over any object they own.
• There are two important concepts in DAC:
1. File and data ownership- every object has an owner. The access
policy to this object is determined by its owner.
2. Access rights permissions:- This is the control that an owner can
assign to other objects for specific resources.
• E.g. Facebook share – You can specify who gains access to resources
you create.

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security;
88
2) State various ways of securing a
database.
MANDATORY ACCESS CONTROL
• MAC: Allowing user to a resource if and only if rules exist that
allow a given user to access the resource.
• In MAC only the administrator manages the access controls.

Read more: Understanding data


processing textbook.

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security;
89
2) State various ways of securing a
database.
DATABASE AUDITING
• Database auditing involves observing a database so as to be
aware of the actions of database users. Database administrators
and consultants often set up auditing for security purposes, for
example, to ensure that those without the permission to access
information do not access it.

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security; 90

2) State various ways of securing a


database.
91
AUTHENTICATION
• Database authentication is the process or act of confirming that
a user who is attempting to log in to a database is authorized to
do so, and is only accorded the rights to perform activities that
he or she has been authorized to do.
• It may be performed by
a. the database itself,
b. the operating system,
c. a network service
d. the secured socket layer (SSL)

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security; 92

2) State various ways of securing a


database.
DATABASE ENCRYPTION
• Database encryption is a process that uses an algorithm to
transform data stored in a database into a form that is
incomprehensible without first being decrypted.
• A "meaningless" encrypted data is of little or no use for
hackers.
• There are multiple techniques and technologies available for
database encryption.

Topic: Database Security


At the end of this topic students
should be able to
1) Define database security;
2) State various ways of securing a
93
database.
TUTORIAL QUESTION

• If an individual steals a hard disk of an organisation, he will be able


to access the information stored and read it. Describe the method
you can use to prevent the hard disk content from being read, even
if it can be accessed.

• How will the authorised user be able to read the encrypted data?

94
BACKUP
• This refers to creating a copy or archiving of the data
that exist in the database outside the database.
• Such backup becomes useful to restore the database in
case of data loss or system crash.
• Backups can be automated to run at a particular time or
done manually.
Tutorial Question:
• Outline 5 situations where data backup will prove
useful.

Topic: Database Security


At the end of this topic students should
be able to
1) Define database security;
95
2) State various ways of securing a
database.
DATABASE ADMINISTRATOR
He manages the database in the following ways.
1. He develops a security policy for the database
2. He creates new users
3. He assigns roles to each user of the database.
4. He handles database auditing

• Tutorial Question: Write 5 more duties of a database


administrator.
Topic: Database Security
At the end of this topic students should
be able to
1) Define database security;
96
2) State various ways of securing a
database.
DATABASE CRASH RECOVERY
• The recovery manager of a DBMS is responsible for ensuring that
transactions survive system crashes.
• Recovery manager ensures atomicity and durability.
• It is called on during a system failure. Hence, it ensures storage
stability
• One of the ways this is achieved is to use a set of disks for storing
information rather than using a single disk.

Topic: Database Crash Recovery


At the end of this topic students should
be able to
1) Define database crash recovery
97
2) Describe the stages of database
recovery.
TUTORIAL QUESTION
• What is database
• atomicity?
• Durability?

Topic: Database Crash Recovery


At the end of this topic students should
be able to
1) Define database crash recovery
98
2) Describe the stages of database
recovery.
ARIES
• Algorithm for Recovery and Isolation Exploiting Semantic
• When there is media failure, the recovery manager starts a
recovery process in three stages as shown below:
• Analysis
• Redo
• Undo

Topic: Database Crash Recovery


At the end of this topic students should
be able to
1) Define database crash recovery
99
2) Describe the stages of database
recovery.
ARIES
1. Analysis: Identifies dirty pages in the buffer pool and active
transactions at the time of crash.

2. Redo: Repeats all transactions/actions starting from an


appropriate point in the log and restores the database state to
what it was at the time of the crash.

3. Undo: The recovery manager undoes the actions of the


transactions that did not commit, so that the database reflects
only the actions of committed transactions.
Topic: Database Crash Recovery
At the end of this topic students should
be able to
1) Define database crash recovery 100
2) Describe the stages of database
recovery.
DEVELOP NOTES

Define

1. Write -Ahead log protocol


2. Explain Check pointing

Use the recommended textbook.

101
ASSIGNMENT

WHAT IS A COMMITTED
TRANSACTION IN DATABASE?
STATE EXAMPLES.

102
TUTORIAL QUESTION
• Make a note on ACID wrt databases.

Topic: Database Crash Recovery


At the end of this topic students should
be able to
1) Define database crash recovery
103
2) Describe the stages of database
recovery.
• Database Commit

• More information at
• www.techopedia.com/definition/16/commit

Topic: Database Crash Recovery


At the end of this topic students should
be able to
1) Define database crash recovery
104
2) Describe the stages of database
recovery.
COMPUTER PROTECTION
1. Do not open mails that you do not know the sender
2. Visit only trusted sites- some online security tools will mark
out safe sites when you surf
3. Avoid using pirated software
4. Install internet security tools like Norton Internet security,
etc.
5. Keep your firewalls running
6. Use strong passwords for your online applications so it will
not be easy to guess
Topic: Computer Protection
At the end of this topic students should
be able to
1) State ways of protecting the
105
computer from infections.
7. Avoid revealing all your personal and private details on
social networks or your blogs. Go to privacy settings and
make adjustment. This could lead to identity theft.

8. Download files from trusted sites alone as viruses can


piggy-back on such files.

NB: A firewall prevents some programs on your computer from


accessing the net without your consent
It also prevents access to your computer by unauthorized
person or running applications on your computer without
you knowing
Topic: Computer Protection
At the end of this topic students should
be able to 106

1) State ways of protecting the


computer from infections.
TUTORIAL QUESTION

• Write a short note on firewalls

Topic: Computer Protection


At the end of this topic students should
be able to
1) State ways of protecting the
107
computer from infections.
DELETE AN ATTRIBUTE

ALTER TABLE StudentData DROP Column DOB

108
QUESTIONS

1. The SELECT statement is used to ______

2. What will be the effect of the code:


SELECT * FROM tbl

109
QUERY BY EXAMPLE (QBE)
• Query by example (QBE) is a query method implemented in
most database systems, most notably for relational databases.
• It is a graphical query language where users can input
commands into a table like conditions and example elements.
• In the background, the user’s operations are transformed into a
database manipulation language such as SQL, and it is this SQL
statement that will be executed in the background.

110
QUERY BY EXAMPLE (QBE)
• Do your query from design view
• Run the query
• Right click on the query tab
• And select View SQL

111
PRACTICAL TASK
• Open MS Access and create a database named “Yourname-
QBE”
• Create a table with the following data or similar and data
types:

CA1
ADM_NUM STNAME Act1 Act2
CLASS (text) Test (Number)
(text) (Text) (Number) (Number)
18/2136 Okedele SS3A 20 20 19
18/2190 Ojo SS3A 18 15 7
18/2224 Golibe SS3A 20 5 8

112
QBE PRACTICE TASK
• Enter the following into a database.
• Generate the total using QBE.
• Use QBE to display only those whose scores are greater than 30
in the result-set.

CA total
ADM_NUM STNAME CLASS CA1 CA2
(text) (Text) (text) (Number) (Number)
18/2136 Okedele SS3A 20 20

18/2190 Ojo SS3A 18 15

18/2224 Golibe SS3A 20 5

113
INTEGRITY CONSTRAINTS OVER
RELATION
• The data stored in a database must satisfy certain
consistency constraints.
• Example: The scores of a student cannot be a negative
value.
• This can be defined so that it is checked every time the
database is updated.

• We have three types of integrity constraints:-

114
1. ENTITY INTEGRITY
• Entity integrity rule states that every table must have a
primary key and that the column or columns chosen as
primary key must be unique and not NULL.

115
2. DOMAIN INTEGRITY
• Domain integrity specifies that all columns in a relational
database must be declared upon a defined domain.
• A domain is a set of values of the same type.
• It is the validity of entries for a given column. This is done by
restricting the data type, data format or range of possible values
(through foreign constraints, Check constraints, DEFAULT
definitions, NOT NULL definitions, and rules)

116
3. REFERENTIAL INTEGRITY
• This preserves the defined relationships between tables when
records are inserted or deleted.
• Example: there is a foreign key value without a corresponding
primary key value in the referenced table. Record 2 in the second
table has no link to the primary table. The record existed but was
deleted. If referential integrity was enforced, this would not have
taken place.

Artist_Id Artist_name

1 Clement Artist_Id Album_id Album_name


2 Bruno 3 1 Crave

3 Greens 4 2 Pluto
5 3 Gadget
5 Henry
117
COMPUTER SECURITY

• Computer security is associated with three core areas:


1. Confidentiality- Ensuring that information is not accessed by
unauthorised users
2. Integrity – ensuring that information is not altered by
unauthorised persons
3. Authentication – Ensuring that users are the persons they
claim to be.

118

You might also like