Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views25 pages

E-Note SS Two 1st Term Data Processing

Uploaded by

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

E-Note SS Two 1st Term Data Processing

Uploaded by

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

FIRST TERM E-LEARNING NOTE

SUBJECT: DATA PROCESSING CLASS: SS 2


SCHEME OF WORK
WEEK TOPIC
1. Data Models: (a) Definition of Data model (b) Concept of Data Modelling (c)
Type of data models (d) Levels of data models
2. Data Modelling I: (a) Organization of Database using MS Access (b) Creating
Database, Files (Tables), Fields with Datatypes
3. Data Modelling II: (a) Creating Forms, Queries and Reports (b) Significance
of Data Model (c) Standard data models
4. First Continuous Assessment
5. Normal Forms I: (a) Concept of Normalization (b) Definition of Normal
Forms (c) Normalization Rules (Types of Normal Forms)
6. Normal Forms II: (a) Problems of table in first normal form (b) Determinant
of normal forms (c) Keys
7. Mid-Term Break
8. Entity Relationship Model: (a) Entities, attributes and relationship (b)
Additional features of entity model
9. Second Continuous Assessment
10.Relational Model: (a) Creating and modifying relations using SQL (b)
Integrity constraints over relations.
11.Revision
12.Examination
13.Examination/Closing

Reference Book
A textbook of Data Processing for SSS 2 by Adedapo F O and Mitchell A. S
WEEK ONE
TOPIC: DATA MODELS

CONTENT:
1. Definition of Data Model
2. Concept of Data Modelling
3. Type of data model
4. Levels of Data Model (Approach)

SUBTOPIC 1: Definition of Data Model


Data Models are fundamental entities to introduce abstraction in a DBMS. Data abstraction
is the reduction of a particular body of data to a simplified representation of the whole.
Abstraction, in general, is the process of removing characteristics from something to reduce it
to a set of essential elements. To this end, data abstraction creates a simplified
representation of the underlying data, while hiding its complexities and associated
operations. Data models define how data is connected to each other and how they are
processed and stored inside the system.

A data model is an abstract model that organizes elements of data and standardizes how
they relate to one another and to properties of the real-world entities. For instance, a data
model may specify that the data element representing a car be composed of a number of
other elements which, in turn, represent the color and size of the car and define its owner.

SUBTOPIC 2: Concept of Data Modelling


Data modelling techniques are tools help to capture and translate complex systems designs
into easily understood representation of data flows and processes, creating a blueprint for
construction and re-engineering.

Data models provide a structure for data used within information system by providing
specific definition and format.

Data model shows the dataflow and logical interrelationship among different data elements.

Compatibility of data can be achieved, if a data model is consistently used across the
systems.

The term data model actually refers to two different things: a description of data structure
and the way data are organized using Database Management System (DBMS).

Data Structure: A data model describes the structure of the data within a given domain and,
by implication, the underlying structure of that domain itself.

Data Organization: A data model also describes how to organize data using a database
management system.

SUBTOPIC 3: Types of Data Model


There are six major types of data model
1. Database Model
2. Data Structured Diagram
3. Entity-relationship model
4. Geographic data model
5. Generic data model
6. Semantic data model

Database Model:
A database model is a specification describing how a database is structured and used.
FHNROS
Types of Database Model
i. Flat model: The flat model is the earliest, simplest data model. It simply lists all the data
in a single table, consisting of columns and rows. In order to access or manipulate the
data, the computer has to read the entire flat files into memory, which makes this model
inefficient for all but the smallest data sets.
ii. Hierarchical model: The hierarchical model organizes data into a tree-like structure,
where each record has a single parent or root. Sibling records are sorted in a particular
order. That order is used as the physical order for storing the database. This model is
good for describing many real-world relationships.

iii. Network model: This model organizes data using two fundamental constructs, called
records and sets. Records contain fields, and sets define one-to-many relationships
between records: one owner, many members. The network data model is an abstraction
of the design concept used in the implementation of databases.

iv. Relational model: The most common model, the relational model sorts data into tables,
also known as relations, each of which consists of columns and rows. Each column lists
an attribute of the entity in question, such as price, zip code, or birth date. Together, the
attributes in a relation are called a domain.
v. Object-relational model: This hybrid database model combines the simplicity of the
relational model with some of the advance functionality of the object-oriented database
model. In essence, it allows designers to incorporate objects into the similar table
structure.
vi. Star Schema: A star schema is a multi-dimensional data model used to organize data in a
database so that it is easy to understand and analyze. Star schemas can be applied to da
warehouses, databases, data marts and other tools. The star schema design is optimized
for query large data sets.

Data Structure Diagram


A data structure diagram (DSD) is a diagram and data model used to describe conceptual
data models by providing graphical notations which document entities and
their relationships, and the constraints that bind them.
Data structure diagrams are an extension of the entity-relationship model. In
DSDs, attributes are specified inside the entity boxes rather than outside of them, while
relationships are drawn as boxes composed of attributes which specify the constraints that
bind entities together.

Entity-relationship model
An entity-relationship model (ERM), sometimes referred to as an entity-relationship diagram
(ERD), is an abstract conceptual data model (or semantic data model) used in software
engineering to represent structured data. It depicts relation among people, objects, places,
concepts or events within an Information Technology (IT) system. There are several
notations used for ERMs

Teacher Teaches CLASS

Geographic data model


A data model in Geographic information systems is a mathematical construct for
representing geographic objects or surfaces as data.

Generic data model


Generic data models are generalizations of conventional data models. They define
standardized general relation types, together with the kinds of things that may be related by
such a relation type. Generic data models are developed as an approach to solve some
shortcomings of conventional data models. For example, different modelers usually produce
different conventional data models of the same domain

Semantic data model


A semantic data model in software engineering is a technique to define the meaning of data
within the context of its interrelationships with other data. A semantic data model is an
abstraction which defines how the stored symbols relate to the real world. A semantic data
model is sometimes called a conceptual data model.

SUBTOPIC 4: Levels of Data Model (Approach)


There are different levels to data model, including;
i. Conceptual Data model
ii. Logical Data Model
iii. Physical Data Model

Conceptual Data Model: is a technology independent specification of the data to be held in


the database. It is the focus of communication between the data modeler and business
stakeholders, and it is usually presented as a diagram with supporting documentation.

Logical Data Model: is the translation of the conceptual model into structure that can be
implemented using a database management system (DBMS).
This model specifies tables and columns. These are the basic building blocks of relational
databases, which are implemented using a relational database management system
(RDBMS)
Physical Data Model: this incorporates any changes necessary to achieve adequate
performance and is also presented in terms of tables and columns, together with a
specification of physical storage and access mechanisms.
EVALUATION:
i. What is conceptual data model?
ii. What does data model focus on?
iii. What is logical data model?
iv. Discuss the different approach to data model
v. State the concept of data modelling.
vi. Describe the following: Data Structure and Data Organization.

READING ASSIGNMENT:
Study the topic ‘Data modelling” using students’ textbook

WEEKEND ASSIGNMENT:
OBJECTIVE TEST:
1. In a database data is organized into simple (a) tables (b) rows (c) columns (d) type
2. A data model is a ___ representation of the data structure that are required by a
database. (a) logical (b) conceptual (c) physical (d) dynamic
3. The following is not a step of design process: (a) planning (b) logical design (c) survey
(d) implementation
4. The term “Data Model” refers to two different things, data organization and
____________ (a) data model (b) data processing (c) data structure (d) data organization
5. The process of structuring and organizing data is referred to as __________ (a) data
structure (b) data organization (c) data manipulation (d) data modelling
WEEK TWO

TOPIC: DATA MODELLING I

CONTENT:
1. Organization of Database using MS Access
2. Creating Database, Files (Tables), Fields with Datatypes

SUB-TOPIC 1: Organization of Database using MS Access


Database packages are used to design a database in a computer. Example of a common
database package is Microsoft Access. MS Access is a Relational Database Management
System used to create and modify databases.

To create a database on the computer with MS Access


Load MS Access: do the following
 Click on the Start Menu
 Point to all program
 Point to Microsoft Office
 Click on Microsoft Office Access

SUB-TOPIC 2: Creating Database, File (Tables), Fields with Datatypes


Data Modelling in software engineering is the process of creating a data model by applying
formal data model descriptions using data modeling techniques.

Data modeling is a method used to define and analyze data requirements needed to support
the business processes of an organization. The data requirements are recorded as a
conceptual data model with associated data definitions. Actual implementation of the
conceptual model is called a logical data model.

Creating Database
1. From the displayed window, click on blank database
2. By the right-hand side of the windows, where the arrow is pointing in the picture-screen
above, click inside the file name text box and type the desired database name.
3. Click on create command button. A database with the filename given will be created.

Generally, creating a database using any DBMS entails the following basic steps:
 Define the database structure
 Specify field type
 Input Data

Define the database structure:


The database structure specifies the type of database organization that should be used. If
the relational form is selected, the database structure will include RDBMS, structure of the
table, number of rows, number of columns, the key, and relationship of the database, etc.

Specify field type


When a database is being created, all fields are set to accept a particular type of input by
specifying a field type. A field type is also known as a Data type. The essence of a data type is
to prevent a wrong input from being stored in a database (i.e. database integrity). Usually
the name of a data type varies with DBMS but portrays a general meaning. These include:
 Alpha numeric/text field: Fields that accepts both numbers and text e.g. ASP2548
 Numeric Fields: Fields that accepts numbers in two forms: Real number i.e. decimal
numbers e.g. 8, 15, 9.1 and integers’ i.e. whole numbers e.g. 125, 80, etc.
 Data fields: They store data in date format e.g. 11-04-2009
 Boolean Fields: The data accepted by these fields are either Yes/No or True/False
 Memo: Long text. Use for long pieces of text. Such as notes and long description. Can
store up to 64,000 characters.
 Currency: Use for currency
 Auto-number: Unique sequential numbers or random number automatically inserted
when you create a record. Use to create primary key.
 Hyperlink: Use to store hyperlink
 Attachment: Use to store attachments e.g. files, images, etc.
 OLE object: Use to attach an OLE object such as word document, spreadsheet, or
Powerpoint presentation.

Input Data
After the field names and their data types have been specified, then records are stored in
the database by specifying the appropriate input. In MS Access, to input a data;
 Double click on the Student Tale at the left-hand pane of MS Access windows
 Enter the data beneath the field names and click on the next cell to populate data.

To keep database updated, data inputted into the database must be saved regularly.
Keyboard command CTRL+S is used. Alternatively, you click on the office button and save.

Creating a file
Files are created as tables in the database.
1. Click on create menu and select table
2. At all tables tab, right click on any of the table
3. Select design view
In the save as dialog box, type a desired table name (e.g. Student Table) in the Table name
text box and click ok.

Tables in database on a computer are composed of rows and columns. A table in MS Access
is organized into rows and columns like the picture screen shown below.
Creating Fields with Data Types
Fields are assigned field names relevant to the information they keep. Field names are
assigned data types which determine the kind of data they accept as input. For example, in
MS Access Table above, Surname are alphabetic, the fields will not accept numeric
(numbers) inputs 10 or 500 as surname. To set data type for filed in MS Access, follow the
step below:
 After creating the table in design view under the field name tab, then type the field name
and under the data type table next to the field name, click the drop down menu and
select AutoNumber as shown below

For example, using the above picture screen, the field name ID number will be assigned
Number data type since the ID numbers will be numeric. In the same way, TEXT data type
will be assigned to Surname, Firstname and Othername.

Unique Identifier
A table contains a unique identifier i.e. a KEY. In MS Access, a default primary key is usually
specified for the first field. To set another field of your choice as primary key, right click on
the first cell and select Primary key.

Editing data type in fields


When creating tables, you should define the data types of the table to the most closely
match the type of data that will be entered in the field.

To edit data type in Data sheet view:


1. Click the filed you wish to define
2. Click the datasheet tab on the Ribbon
3. Click the down arrow next to Data type
4. Choose the type of data that will be entered into the field

To edit the data of the format:


1. Click the field you wish to define
2. Click the datasheet tab on the ribbon
3. Click the down arrow next to the format

To edit Data type in the design view:


1. Click the design view
2. Click the field name you wish to define or create (for new field)
3. Click the Data type
4. Choose the appropriate Data type
5. Format the field in the Field Properties dialog box.

To delete a Table
1. Open the desired database by clicking the Microsoft office button and clicking open
2. Right click on a table and choose delete

To rename a Table
1. Open the desired database by clicking the Microsoft office button and clicking open.
2. Right click on a table and choose Delete.
3. Type in the new name.

EVALUATION:
1. How is database created?
2. What are the basic steps that entails creating a database?
3. What are the datatypes you can specify in MS-Access?
4. How do you create fields with datatypes?

GENERAL EVALUATION
1. Write down steps on how to perform the following on MS Access
- To edit data-type
- Delete a table
- Rename a table
2. Write down steps on how to load MS Access

WEEKEND ASSIGNMENT
1. Another name for field type is known as __________ (a) file type (b) name type (c)
record type (d) data type
2. Another name for unique identifier is known as __________ (a) key (b) data (c) field (d)
record
3. _________ is an attribute or field that can be used to identify a record in a database
table or file. (a) Data (b) Field (c) Key (d) Table
4. ________ is used to design a database in a computer. (a) Database package (b) Graphics
package (c) Spreadsheet package (d) Word Processing
WEEK THREE

TOPIC: DATA MODELLING II

CONTENT:
1. Creating Forms, Queries and Reports
2. Significance of Data Model
3. Standard Data Model

SUB-TOPIC 1: Creating Forms, Queries and Reports


Creating Forms
Forms allows you to enter, edit or display data. They are based on tables. With forms, you
can choose format and arrangement the fields will take or will be displayed.

To create a form:
1. Open the navigation pane
2. Click the table or query on which you want to base your form
3. Activate the create tab
4. Click form in the forms group
After you create a form, you can save it. You can also open a saved form at any time.
5. Click the save button on the quick access toolbar
6. Type the name you want to give the form
7. Click OK. You can access the form by clicking the navigation pane.

Form Wizard
You can create forms with the help of a form wizard. On the create table, click the more
forms down.
1. Click Form Wizard
2. Choose the Table/Queries that you wish to have on the form
3. Choose the field you wish to have on the forms
4. Click Next
5. Choose the layout for the form
6. Click Next
7. Choose style
8. Click Next
9. Create a title for the form
10. Choose whether you want to open the form to view it or modify the form’s design
11. Click finish

Creating Query
The Query wizard walks you through the steps to set up a query. To run a query using the
query wizard
1. Click the create tab
2. Click the query wizard button under group
3. Choose the type of query you wish to urn
4. Click OK

To choose the field you wish to include from each table


1. To select fields from different tables, click the Tables/Queries down arrow
2. Click OK
To insert picture of query wizard
3. Type in a title for the query
4. Click finish
5. The query will be displayed

Creating Report
Reports organize and summarize data for viewing online or for printing. A detail report
displays all of the selected records. Reports are a means to view and analyze large amount of
data. You can use the report wizard or create a custom report that meets your specific need.
1. Click the Blank report button on the Create Tab
2. Click the Add Existing fields button
3. From the field list, click and drag the fields to the report

Creating using Report Wizard


4. On the Create tab, click, the report Wizard button
5. Choose the Tables/Queries that you wish to have on the form
6. Choose the field you wish to have on the forms
7. Click Next
8. Choose the sort order for your report
9. Choose the layout for the form
10. Click Next
11. Choose a style
12. Click Next
13. Create a title
14. Choose whether you want to open the form to view it or modify the form’s design
15. Click Finish

SUB-TOPIC 2: Significance of Data Model


Data model is a great communication tool because it facilitates interaction and
communication between the designers, programmers and end users. In essence it does not
allow one party’s bias towards a certain view of a data (whether they consider to be most
important) to take hold.
 A well-developed data model can even foster improved understanding of the
organization for which the database design is developed.
 Data model help in structuring and organizing data. These data structure are then
typically implemented in a database management system which is used mostly by
organization for decision making.
 In addition to defining and organizing the data, data modelling will impose (implicitly or
explicitly) constraints or limitation on the data placed within the structure.

SUB TOPIC 3: Standard Data Model


A standard data model or industry standard data model (ISDM) is a data model that is widely
applied in some industry, and shared amongst competitors to some degree. They are often
defined by standards bodies, database vendors or operating system vendors.

When in use, they enable easier and faster information sharing due to the fact that
heterogeneous organization have a standard vocabulary and pre-negotiated semantics,
format, and quality standards for exchange data. The standardization has an impact on
software architecture as solutions that vary from the standard may cause data sharing issues
and problems if data is out of compliance with the standard.
The most effective standard models have developed in the banking, insurance,
pharmaceutical and automotive industries, to reflect the stringent standards applied to
customer information gathering, customer privacy, consumer safety, or just in time
manufacturing.

The most complex data models known are in military use, and consortia such as NATO tend
to require strict standards of their members’ equipment and supply database. However,
they typically do not share these with non-NATO competitors, and so calling these ‘standard’
in the same sense as commercial software is probably not very appropriate.

Example of Standard Data Models


1. ISO 10303: ISO 10303 is an ISO standard for the computer-interpretable representation
and exchange of product manufacturing information.
2. ISO 15926: The ISO 15926 is a standard for data integration, sharing, exchange, and
handover between computer systems.
3. IDEAS Group: The IDEA Group is the International Defence Enterprise Architecture
Specification for Exchange Group. The deliverable of the project is a data exchange
format for military Enterprise Architectures.

EVALUATION:
1. What is a form?
2. How would you create a form?
3. What are the examples of standard data model?
4. Explain standard data model.
5. What is the significance of data modeling?
6. What is another name for “standard data model”?
7. State two examples of standard data model

READING ASSIGNMENT:
Study the topic ‘Data modelling” using students’ textbook

WEEKEND ASSIGNMENT:
OBJECTIVE TEST:
1. In a database data is organized into simple (a) tables (b) rows (c) columns (d) type
2. A data model is a ___ representation of the data structure that are required by a
database except. (a) logical (b) conceptual (c) physical (d) dynamic
3. The following is not a step of design process: (a) planning (b) logical design (c) survey
(d) implementation
4. Creating a Query, choose the following from New Query dialog box. (a) creating query
wizard (b) design view (c) simple query wizard (d) none of the above
5. Standard Data Model can also be called ________ (a) Manufacture Standard Data Model
(b) Industry Standard Data Model (c) Structured Standard Data Model (d) Enhanced
Standard Data Model
6. ______ are great communication tool because it allows interaction and communication
between designers, programmers and end users. (a) Data model (b) Normal form (c)
Database (d) Attribute
7. What is the full meaning of ISDM? (a) Industry significant data model (b) International
standard data model (c) International significant data model (d) industry standard data
model
8. _________ is the international defense enterprise architecture specification for exchange
group. (a) Ideas Group (b) Standard Group (c) Best Group (d) Normal Group
WEEK FOUR: First Continuous Assessment (1st CA)
WEEK FIVE:
TOPIC: NORMAL FORMS I

CONTENT:
1. Concept of Normalization
2. Definition of Normal Form
3. Normalization Rules (Types of Normal Forms)

Sub-topic 1: Concept of Normalization


A database management system is a collection of computer software that enables users to
define, create and maintain database. Defining a database involves specifying constraints for
the data stored in the database, and normalization is a logical design method which
minimizes duplicates, or redundant data and design flaws.

Normalization is the process of effectively organizing data in a database. Database


Normalization is a technique of organizing the data in the database. Normalization is a
systematic approach of decomposing tables to eliminate data redundancy and undesirable
characteristics like Insertion, Update and Deletion Anamolies. It is a multi-step process that
puts data into tabular form by removing duplicated data from the relation tables.

Normalization is used for mainly two purposes:


 Eliminating redundant (useless) data.
 Ensuring data dependencies make sense i.e data is logically stored.

Problem Without Normalization


Without Normalization, it becomes difficult to handle and update the database, without
facing data loss. Insertion, Updation and Deletion Anamolies are very frequent if Database is
not Normalized. To understand these anomalies let us take an example of Student table.
S_id S_Name S_Address Subject_opted
401 Adam Noida Bio
402 Alex Panipat Maths
403 Stuart Jammu Maths
404 Adam Noida Physics
 Updation Anamoly: To update address of a student who occurs twice or more than twice
in a table, we will have to update S_Address column in all the rows, else data will
become inconsistent.
 Insertion Anamoly: Suppose for a new admission, we have a Student id(S_id), name and
address of a student but if student has not opted for any subjects yet then we have to
insert NULL there, leading to Insertion Anamoly.
 Deletion Anamoly: If (S_id) 401 has only one subject and temporarily he drops it, when
we delete that row, entire student record will be deleted along with it.

Sub-topic 2: What is Normal Form?


The Normal form (NF) of relational database theory provide critical for determining a table’s
degree of vulnerability to logical inconsistencies and anomalies. The higher the normal form
applicable to a table, the less vulnerable it is. Each table has a “Highest Normal Form” (HNF):
by definition, a table always meets the requirements of its HNF and all normal forms lower
than its HNF; also by definition, a table fails to meet the requirement of any normal form
higher than its HNF.
Normal form theory deal with how to reduce the amount of redundancy of data within a
given table. Each normal form represents a level. To satisfy each the requirements for
certain level, the requirements for the previous level must be met. To reach the optimal
normal form for the tables within a database, the creator starts with a large list of all the
data that is to be held in the database, and then works through the normal forms until he
can no longer break the data down into smaller table.

Sub-topic 3: Normalization Rule (Types of Normal Form)


Normalization rule are divided into the following normal form.
1. First Normal Form
2. Second Normal Form
3. Third Normal Form

First Normal Form (1NF)


As per First Normal Form, no two Rows of data must contain repeating group of information
i.e each set of column must have a unique value, such that multiple columns cannot be used
to fetch the same row. Each table should be organized into rows, and each row should have
a primary key that distinguishes it as unique. The Primary key is usually a single column, but
sometimes more than one column can be combined to create a single primary key.

In 1NF, the following rules are observed;


1. Eliminating repeating information
2. Create separate tables for related data.

For example consider a table which is not in First normal form


Student Table:
Student Age Subject
Adam 15 Biology, Maths
Alex 14 Maths
Stuart 17 Maths

In First Normal Form, any row must not have a column in which more than one value is
saved, like separated with commas. Rather than that, we must separate such data into
multiple rows.

Student Table following 1NF will be:

Student Age Subject


Adam 15 Biology
Adam 15 Maths
Alex 14 Maths
Stuart 17 Maths
Using the First Normal Form, data redundancy increases, as there will be many columns with
same data in multiple rows but each row as a whole will be unique.

Second Normal Form (2NF)


As per the Second Normal Form there must not be any partial dependency of any column on
primary key. It means that for a table that has concatenated primary key, each column in the
table that is not part of the primary key must depend upon the entire concatenated key for
its existence. If any column depends only on one part of the concatenated key, then the
table fails Second normal form.

The 2NF further addresses the concept of removing duplicate data. The rule for the second
normal form is;
1. Remove subsets of data that apply to multiple rows of a table and place them in separate
table
2. Create relationships between these new tables and their predecessors through the use
of foreign keys.

In example of First Normal Form there are two rows for Adam, to include multiple subjects
that he has opted for. While this is searchable, and follows First normal form, it is an
inefficient use of space. Also in the above Table in First Normal Form, while the candidate
key is {Student, Subject}, Age of Student only depends on Student column, which is incorrect
as per Second Normal Form. To achieve second normal form, it would be helpful to split out
the subjects into an independent table, and match them up using the student names as
foreign keys.

New Student Table following 2NF will be:


Student Age
Adam 15
Alex 14
Stuart 17
In Student Table the candidate key will be Student column, because all other column i.e Age
is dependent on it.

New Subject Table introduced for 2NF will be:


Student Subject
Adam Biology
Adam Maths
Alex Maths
Stuart Maths
In Subject Table the candidate key will be {Student, Subject} column. Now, both the above
tables qualifies for Second Normal Form and will never suffer from Update Anomalies.
Although there are a few complex cases in which table in Second Normal Form suffers
Update Anomalies, and to handle those scenarios Third Normal Form is there.

Third Normal Form (3NF)


Third Normal form applies that every non-prime attribute of table must be dependent on
primary key, or we can say that, there should not be the case that a non-prime attribute is
determined by another non-prime attribute. So this transitive functional dependency should
be removed from the table and also the table must be in Second Normal form.

There are two basic requirements for a database to be in Third Normal Form:
1. The requirements of both 1NF and 2NF must have been met.
2. Remove columns that are not fully dependent upon the primary key.
For example, consider a table with following fields.
Student_DetailTable :
Student_id Student_name DOB Street city State Zip
In this table Student_id is Primary key, but street, city and state depends upon Zip. The
dependency between zip and other fields is called transitive dependency. Hence to apply
3NF, we need to move the street, city and state to new table, with Zip as primary key.

New Student_DetailTable :
Student_id Student_name DOB Zip

Address Table :
Zip Street city state
The advantage of removing transitive dependency is,
 Amount of data duplication is reduced.
 Data integrity achieved.

N/B: The Fourth and the Fifth normal form are beyond the scope of this scheme.

EVALUATION:
1. What is normalization?
2. Explain normal form
3. State the two goals of normalization process
4. What is 1NF?
5. State the rules for carrying out 1NF, 2NF and 3NF

READING ASSIGNMENT:
Study the topic ‘Normal Forms” using students’ textbook

WEEKEND ASSIGNMENT:
OBJECTIVE TEST:
1. __________ normal form says that all columns values must be atomic. (a) 1NF (b) 2NF (c)
3NF (d) 4NF
2. _________ normal form must meet the requirement of first and second. (a) 1NF (b) 2NF
(c) 3NF (d) 4NF
3. One of the following is a basic requirement for database to be in the third normal form
(a) remove columns that are not fully dependent upon the primary key (b) Create
relationship between the new tables (c) Eliminate repeating information (d) remove
subsets of data that apply to multiple rows
4. How many value(s) exist in 1NF for every row-by-column position in a given table? (a)
one (b) two (c) three (d) four
5. A table always meets the requirement of its ____ form.
6. The normal forms are applicable to individual ______
WEEK SIX:
TOPIC: NORMAL FORMS II

CONTENT:
1. Problems of Table in First Normal Form
2. Determinant of Normal Forms
3. Keys

Sub-topic 1: Problems of table in first normal form


Consider the employee table below

Employee Employee Department Name Qualification


Number Name
01287 Clark Auditing Bachelor of Art
22617 Walsh Auditing Master of Art
70964 Smith Legal Doctor of Philosophy
50607 Black Auditing Bachelor of Art

From the table above, the basic problem is that department names and addresses are really
data about departments rather than employees, and belong to a separate Department
table. We therefore establish a third table for department data, resulting in the three-table
model below:

Employee table
Employee Number Employee Name Department Number
01287 Clark 05
22617 Walsh 05
70964 Smith 12
50607 Black 05

Department Table
Dept. Number Dept Name Dept. Location
05 Auditing HQ
12 Legal MS

Qualification Table
Employee Number Qualification Description Qualification year
01287 Bachelor of Art 1970
22617 Master of Art 1973
70964 Doctor of Philosopy 1976
50607 Bachelor of Art 1969

We leave Department number in the Employee table to serve as a cross-reference, in the


same way that we retained Employee Number in the Qualification table. Our data now
normalized.

Sub-topic 2: Determinants of Normal Forms


It is important to understand that this whole procedure of separating hospital data relied on
the fact that for a given hospital number there could be only one hospital name, contact
person, hospital type and teaching status. In fact we could look at the dependency of
hospital data on hospital number as the cause of the problem. Every time a particular
hospital number appeared in the Operation table, the hospital name, contact person,
hospital type and teaching status were the same.

OPERATION (Hospital Number, Operation Number, Hospital name, Hospital Type,


Teaching Status, contact Person, operation Name, Operation code, Procedure
Group, Surgeon Number, Surgeon Specialty)
DRUG ADMINISTRATION (Hospital Number, Operation Number, Drug Short name,
size of dose, Unit of Measure, Method of Administration, Dose Cost, Number of
Doses, Drug name, Manufacturer)

Hospital data removed to separate table.

Formally, we say Hospital Number is a determinant of the other four columns. We can show
this as:
Hospital Number Hospital Name, Contact Person, Hospital Type, Teaching Status
Where we read “ “ as “determines” or “is a determinant of”.

Determinants need not consist of only one column; they can be a combination of two or
more columns, in which case we can use a + sign to indicate such a combination.
E.g. Hospital Number + Operation Number Surgeon Number.
This leads us to a more formal description of the procedure:
1. Identify any determinants, other than the primary key, and the columns they
determine.
2. Establish a separate table for each determinant and the columns it determines. The
determinant becomes the key of the new table.
3. Name the new tables.
4. Remove the determined columns from the original table. Leave the determinants to
provide links between tables.

Sub-topic 3: Keys
A key is an attribute or field that can be used to identify a record in a database table or file.

Primary Keys
The primary key is a unique attribute that can be used to identify a record in a database
table. It is a nominated column or combination of columns that has a different value for
every row in the table. Each table has one (and only one) primary key. When checking this
with a business person, we would say, “if I nominated, say, a particular account number,
would you be able to guarantee that there was never more than one account with that
number?”

For example, in the student database table, the attribute that is unique to identify each
record is the Student-ID or RegNo.

Candidate Keys
Sometimes more than one column or combination of columns could serve as a primary key.
E.g, we could have chosen Drug Name rather than Drug Short Name as the primary key of
the Drug table (assuming, of course, that no two drugs could have the same name). we refer
to such possible primary keys, whether chosen or not, as candidate keys. From the point of
view of normalization, the important thing is that candidate keys that have not been chosen
as the primary key, such as Drug Name, will be determinants of every column in the table,
just as the primary key is.

Foreign Keys
Recall that when we removed repeating groups to a new table, we carried the primary key of
the original table with us, to cross-reference or “point back” to the source. In moving from
first to third normal form, we left determinants behind as cross-reference to the relevant
rows in the new tables.
These cross-referencing columns are called foreign keys, and they are our principal means of
linking data from different tables.

The foreign key is a field in a relational table that matches a candidate key of another table.
A foreign key (FK) is a column or combination of columns that is used to establish and
enforce a link between the data in two tables. You can create a foreign key by defining a
FOREIGN KEY

EVALUATION:
i. What is primary key?
ii. What is the use of foreign keys?
iii. What are candidate keys?

READING ASSIGNMENT:
Study the topic ‘Entity Relational Model” using students’ textbook

WEEKEND ASSIGNMENT:
OBJECTIVE TEST:
1. Foreign key is a field in a relational table that matches a ___ of another table.
(a) candidate key (b) row (c) field (d) none of the above
2. Each value of the primary key uniquely identifies one ___ of the table. (a) column
(b) row (c) field (d) none of the above
WEEK SEVEN: Midterm Break

WEEK EIGHT:
TOPIC: ENTITY RELATIONSHIP MODEL

CONTENT:
1. Entities, attributes and relationship
2. Additional features of entity model

Sub-topic 1: Entities, attributes and relationship

PRODUCT Entity
ProductID

Unit price

Qty on hand Supplied by


Cardinality

Attributes
Name
SUPPLIER
Relationship
Address

The rectangle in the diagram above are called entity type and the ovals are called attributes.
The entities are the ‘things’ in business environment about which we want to store data. The
attributes provide us with a means of organizing and structuring the data.

Entities
Entities are drawn as rectangular boxes containing a noun in singular form.
You will see later that each entity you draw ultimately becomes a table in your database.
You might want to keep this transformation from entity to table in mind when selecting the
names of your entities. E.g. your entity names should be short but descriptive.

Customer

Relationship
A relationship between entities is drawn as a line bisected by a
diamond. The diamond contains a verb (or short verb phrase) that
buys
describes the nature of the relationship between the entities.

Named relationship are used to make the ERDs more readable. However, unlike entity
names, relationship names never show up in the final database.

Attributes
Attributes are properties or characteristics of a particular entity about which we wish to
collect and store data. In addition, there is typically one attribute that uniquely identifies
particular instances of the entity. E.g. each of your customers may have a unique customer
ID. Such attributes are known as Key attributes.
Name
Phone No
CustID

Contact person Customer

Sub-topic 2: Additional features of entity model


Associative entities
Given the number and importance of the attributes attached to the ‘buys’ relationship, it
makes sense to treat the relationship as an entity in its own right. To transform a
relationship into an entity on an ERD, we use a special symbol called an associative entity.
The notation for an associative entity is a relationship diamond nested inside of an entity
rectangle.

Name
Phone No
CustID

Contact person

Sale Product

EVALUATION:
i. What are entities?
ii. What are attributes?
iii. What are associative entities?

READING ASSIGNMENT:
Study the topic ‘Relational Model” using students’ textbook

WEEKEND ASSIGNMENT:
OBJECTIVE TEST:
1. The ___ provide us with a means of organizing and structuring the data.
2. A set of tools and procedures for applying the tools that specifies the notation used
within the organization is called ______
3. To transform a relationship into an entity on an ERD, we use a special symbol called
an (a) Entity (b) Attribute (c) associative entity (d) none of the above
WEEK NINE: SECOND CONTINUOUS ASSESSMENT (2ND CA)

WEEK TEN:
TOPIC: RELATIONAL MODEL I

CONTENT:
1. Creating and modifying relations using SQL
2. Integrity constraints over relations

Sub-topic 1: Creating and modifying relations using SQL


The relational model for database management is a database model based on first –order
predicate logic, first formulated and proposed in 1969 by E.F. Codd.

Activity Activity
Code code
23 Patching
24 Overlay
Activity Date
25 Crack Code Route No
24 01/12/01 1-95
Sealing
24 02/08/01 1-66

Date Activity
Code Route No
01/12/01 24 1-95
01/15/01 23 1-495
02/08/01 24 1-66

Diagram of a sample database according to the relational model

The purpose of the relational model is to provide a declarative method for specifying data
and queries.

Creating and modifying relations using SQL


Creating and modifying relations simply is the process of creating and modifying a database.
Data-definition queries can be very convenient. You can regularly delete and re-create parts
of your database schema merely by running some queries. Consider using a data-definition
query if you are familiar with SQL statements and you plan to delete and re-create particular
tables, constraints, indexes or relationships.

A relation is a table structure definition (set of column definitions) along with the data
appearing in that structure. The structure definition is the heading and the data appearing in
it is the body, a set of rows. A database relvar (relation variable) is commonly known as base
table. Operators called the Update operators are used to interact with the database.
Example, INSERT, UPDATE or DELETE.
SQL
SQL (often referred to as structured query language) is a programming language designed for
managing data in relational database management system(RDBMS). It is use for data insert,
query, update and delete, schema creation and modification, and data access control. SQL
can achieve the following in a database:
a. SQL can execute queries against a database
b. SQL can retrieve data from a database
c. SQL can insert records into a database
d. SQL can update records in a database
e. SQL can delete records from a database
f. SQL can create new databases
g. SQL can create new tables in a database
h. SQL can create store procedures in a database
i. SQL can create views in a database
j. SQL can set permissions on tables, procedures and views.

SQL can be divided into two parts:


1. Data Manipulation Language(DML)
2. Data Definition Language(DDL)
DML is the part that supports query and update commands
KEYWORD USE
SELECT Extract data from a database
UPDATE Updates data in a database
DELETE Deletes data from a database
INSERT Insert new data into a database

DDL part of SQL permits creating and deleting of Databases and database tables.

KEYWORDS USE
CREATE DATABASE Creates a new database
ALTER DATABASE Modifies a database
CREATE TABLE Creates a new table
ALTER TABLE Modifies a table
DROP DATABASE Deletes a database
DROP TABLE Deletes a table
CREATE INDEX Creates an index (search key) it is always an integer
DROP INDEX Deletes an index
ADD Add a column or a constraint to a table

We will be looking at Microsoft Access as an example of a Database application.

SQL CREATE STATEMENT:


The SQL create statement is used for creating database and tables. Take note that SQL
syntax are case sensitive.
1. The CREATE DATABASE Statement: This is used to create a new database. The
syntax(command) is as follows:
CREATE DATABASE database_name
(That is type CREATE then a spacebar, DATABASE then another spacebar then type
the database name then hit Enter).
*NOTE
The syntax CREATE DATABASE must be in Upper case, while the database name is optional
i.e lower or upper case depending on your choice. Then the underscore between database
and name is to make it one word because a database name must be one word no space in
between.
Example:
Write an SQL syntax to create a database called dlhs.
SOLUTION:
CREATE DATABASE dlhs
2. The CREATE TABLE Statement: This is used to create a table in a database. The
syntax(command) is as follows:
CREATE TABLE table_name
(That is, type CREATE then a spacebar, TABLE then another spacebar then types the
table name then hit Enter).
The only required elements of a CREATE TABLE command are the CREATE TABLE command
itself and the name of the table, but usually you will want to define some fields or other
aspects of the table. Consider this simple example.
Example:
Suppose that you want to create a table called student to store the names, age, class and the
scores of students offering ICT in your school.
SOLUTION
CREATE TABLE student
(Student_id, FirstName, LastName, Age, Class, Scores)

The empty student table will now look like this:

Student_id FirstName LastName Age Class Scores

The empty table can now be filled with INSERT INTO statement.

1. Go to all program and navigate to Microsoft Access


2. Click on blank Database
3. Enter the name dlhs on the column for database name
4. On the main menu click on Create tab
5. On the Create tab, in the Macros & Code group, click Query Design.
6. Close the Show Table dialog box.
7. On the Design tab, in the Query Type group, click Data Definition.
The design grid is hidden, and the SQL view object tab is displayed.
8. Type the following SQL statement:
CREATE TABLE student (student_id int(10), FirstName varchar(40), LastName
varchar(40), Age int(10), Class varchar(40), Scores int(5))
9. On the Design tab, in the Results group, click Run.

MODIFY A TABLE
To modify a table, you use an ALTER TABLE command. You can use an ALTER TABLE
command to add, modify, or drop (remove) columns or constraints. An ALTER TABLE
command has the following syntax:
ALTER TABLE table_name predicate
where predicate can be any one of the following:
ADD COLUMN field type[(size)] [NOT NULL] [CONSTRAINT constraint]
ADD CONSTRAINT multifield_constraint
ALTER COLUMN field type[(size)]
DROP COLUMN field
DROP CONSTRAINT constraint
Suppose that you want to add a 10-character text field to store information about the grades
of each student. You can do the following:
1. On the Create tab, in the Macros & Code group, click Query Design.
2. Close the Show Table dialog box.
3. On the Design tab, in the Query Type group, click Data Definition.
The design grid is hidden, and the SQL view object tab is displayed.
4. Type the following SQL statement:
ALTER TABLE student ADD COLUMN grades TEXT(10)
5. On the Design tab, in the Results group, click Run.

SUB-TOPIC 2: INTEGRITY CONSTRAINTS OVER RELATIONS


Create a constraint or a relationship
A constraint establishes a logical condition that a field or combination of fields must meet
when values are inserted. Constraints are used to limit the type of data that can go into a
table or a particular field. For example, a UNIQUE constraint prevents the constrained field
from accepting a value that would duplicate an existing value for the field.
A relationship is a type of constraint that refers to the values of a field or combination of
fields in another table to determine whether a value can be inserted in the constrained field
or combination of fields. You do not use a special keyword to indicate that a constraint is a
relationship.
To create a constraint, you use a CONSTRAINT clause in a CREATE TABLE or ALTER TABLE
command. There are two kinds of CONSTRAINT clauses: one for creating a constraint on a
single field, and another for creating a constraint on multiple fields.

Single-field constraints
A single-field CONSTRAINT clause immediately follows the definition of the field that it
constrains, and has the following syntax:
CONSTRAINT constraint_name {PRIMARY KEY | UNIQUE | NOT NULL |
REFERENCES foreign_table [(foreign_field)]
[ON UPDATE {CASCADE | SET NULL}]
[ON DELETE {CASCADE | SET NULL}]}

Multiple-field constraints
A multiple-field CONSTRAINT clause can be used only outside a field-definition clause, and
has the following syntax:
CONSTRAINT constraint_name
{PRIMARY KEY (pk_field1[, pk_field2[, ...]]) |
UNIQUE (unique1[, unique2[, ...]]) |
NOT NULL (notnull1[, notnull2[, ...]]) |
FOREIGN KEY [NO INDEX] (ref_field1[, ref_field2[, ...]])
REFERENCES foreign_table
[(fk_field1[, fk_field2[, ...]])] |
[ON UPDATE {CASCADE | SET NULL}]
[ON DELETE {CASCADE | SET NULL}]}

EVALUATION:
i. What is a constraint?
ii. What is Data manipulation Language(DML)?
iii. Data Definition Language(DDL)?

READING ASSIGNMENT:
Study the topic ‘Integrity constraint” using students’ textbook

You might also like