100% found this document useful (1 vote)
525 views

DP Ss2 Note First Term

The document provides an overview of data modeling concepts and techniques including creating tables, forms, queries and reports in Access. It discusses the different approaches to data modeling and describes how to create tables, forms using form wizard, queries using query wizard and reports using report wizard in Access.

Uploaded by

odunsal5
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
525 views

DP Ss2 Note First Term

The document provides an overview of data modeling concepts and techniques including creating tables, forms, queries and reports in Access. It discusses the different approaches to data modeling and describes how to create tables, forms using form wizard, queries using query wizard and reports using report wizard in Access.

Uploaded by

odunsal5
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 35

SCHEME OF WORK

1. DATA MODELS

2. DATA MODELING 2

3. DATA MODELING 3

4. NORMAL FORMS

5. NORMAL FORMS 2

6. ENTITY RELATIONSHIP MODEL

7. RELATIONAL MODEL

8. RELATIONAL MODEL 2

9. RELATIONAL MODEL 3

10. RELATIONAL MODEL 2

11. FILE ORGANISATION


SUBJECT: DATA PROCESSING
WEEK ONE
DURATION: 45 MINUTES
TOPIC: DATA MODELS
INSTRUCTIONAL MATERIALS: CLASSIC COMPUTER STUDIES BOOK 1, TUTORIAL VIDEOS &
PICTURE MATERIALS
OBJECTIVES: at the end of the lesson, learners should be able to:
1. Definition of Data Model

2. Concept of Data Modelling

CONTENT

Introduction to Data Modelling

The main effort during the system development life cycle (SDLC) was to produce a set of
programs that automates a business process. Processing was the key drivers for information
systems, not the data or information. As the technology and complexity of system grew,
methodologies and modelling techniques were invented to improve the quality of the
deliverables and to ensure that inexperienced programmers could follow repeatable SDLC
processes.

Definition of Data Modelling

Data Modelling is the process of structuring and organizing data. The data structures are then
typically implemented in a database management system. In addition to defining and
organizing the data, data modelling may also impose constraints or limitations on data placed
within the structure.

Managing large quantities of structure and unstructured data is a primary function of


information systems. Data Models describe structured data for storage in data management
system such as relational databases. They do not describe unstructured data such as word
processing documents, email messages, pictures, digital audio and video.
Concept of Data Modelling

 Data modelling techniques and tools help to capture and translate complex system 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 organized data using a database
management system.

Approach in Data Modelling

There are different approaches to data modelling, including;

1. Conceptual Data Modelling: The conceptual data modelling identifies the highest level
relationships between different entities. This is the first step in organizing
the data requirements.
2. Logical Data Modelling: The logical Data modelling illustrates the specific entities, attribute and
relationships involves in a business function. It serves as the basis for the creation of the
physical data model.
3. Physical Data Modelling: The physical Data Modelling represents an application and database-
specific implication of a logical data model and describes the physical means used to store data.

Types of Data Modelling

Flat Model: The flat Model (or Table) model consists of a single, two-dimensional array
of data elements, where all members of a given column are assumed to be similar in values,
and all member of row are assumed to be related to one another.
Flat Model

Route No. Miles Activities

RECORD 1 1 – 95 12 Overlay

RECORD 2 1 -495 05 Parching

RECORD 3 SR – 301 33 Crack Seal

Hierarchical Model: In a hierarchical database, data is organized into an upside-down tree-like


structure, implying a single upward link in each record to describe the nesting, and a sort field
to keep the records in a particular order in each same-level list. Hierarchical structures were
widely used in the early mainframe database management systems.

Network Model: This model organizes data using two fundamental construct, called records
and sets. Records contain fields, and sets define one-to-many relationships between records:
one owner, many members.
Relational Model: The relational model or relational data base model is based on first-order
predicate logic. Its core idea is to describe a database as a collection of predicates over a finite
set of predicate variables, describing constraints on the possible values and combinations of
values.

Object-Relational Model: The object relational model is similar to relational database model,
but objects, classes and inheritance are directly supported in database schemas and in the
query language. An object-relational database can be said to provide a middle ground between
relational databases and object-oriented databases (OODBMS)

Star Schema: The star schema is the simplest style of data warehouse schema. The star schema
consists of a few “fact table” (possibly only one, justifying the name) referencing any number of
dimension tables”. The star schema is considered an important special case of the snowflake
schema.

Class Task

1. State the concepts of data modelling.


2. Describe the following; Data Structure and data Organization.
3. Explain the different approaches to data modelling.
4. Define data modelling
5. Differentiate between Hierarchical and Network Model.
6. Explain Flat data model.

Ticket-Out

Instruction: Choose the correct option from the ones lettered A to D

1. In the approach of data modeling ____ data modeling illustrate the specific entities, attribute
and relationship involved in business function.
2. Conceptual Data Modeling (b) Logical Data Modeling (c) Flat data Modeling (d)
Physical Data Modeling
3. The processing of structuring and organizing data is referred to as (a) Data Structure
(b) Data Organization (c) Data Manipulation (d) Data Modeling
4. The major concept for data modeling is to (a) Translate simple system design to complex
representation of data (b) Translate complex system design to simple representation of data (c)
Translate simple system design to simple representation of data (d) Translate complex system
design to complex representation of data
5. The term “Data Model” refers to two different things- data organization and ________ (a)
Data Model (b) Data Processing (c) Data Structure (d) Data Organization
6. The following are unstructured data Except (a) Video (b) email message (c) Picture (d) Database
7. Define data modeling.
8. List three (3) approaches to Data modeling.
9. State the major concept of Data Modeling.
SUBJECT: DATA PROCESSING
WEEK TWO
DURATION: 45 MINUTES
TOPIC: DATA MODELING 2 (Practical)
INSTRUCTIONAL MATERIALS: CLASSIC COMPUTER STUDIES BOOK 1, TUTORIAL VIDEOS &
PICTURE MATERIALS
OBJECTIVES: at the end of the lesson, learners should be able to:
1. Create tables

2. Create forms

3. Create queries

4. Create reports

CONTENT

Creating Tables

Creating Forms

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

To create a form

 Open the navigation pane

 Click the table or query on which you want to base your form

 Activate the create tab

 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.

 Click the save button on the Quick Access toolbar.

 Type the name you want to give the form.

 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 tab, click the more forms
down arrow.

 Click Form Wizard

 Choose the Table/ Queries that you wish to have on the form

 Choose the field you wish to have on the forms

 Click Next

 Choose the layout for the form

 Click Next

 Choose Style

 Click next

 Create a title for the form

 Choose whether you want to open the form to view it or modify the form’s design

 Click finish

Creating Queries

A query allows you to select and filter data from multiple tables. Queries can be saved and
utilized as often as you need them.

Creating using Query Wizard

The Query Wizard walks you through the steps to set up a query. To run a query using the
query wizard

 Click the create tab

 Click the query Wizard button under other group

 Choose the type of query you wish to run

 Click OK

To choose the field you wish to include from each table


 To select fields from different tables, click the Tables/Queries down arrow

 Click OK

To insert picture of query wizard

 Type in a title for the query

 Click Finish

 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 analyse large amount of data. You
can use the report wizard or create a custom report that meets your specific need.

 Click the Blank report button on the Create Tab

 Click the Add Existing Fields button

 From the field list, click and drag the fields to the report

Creating using Report Wizard

 On the Create tab, click ,the report Wizard button

 Choose the Tables/Queries that you wish to have on the form

 Choose the field you wish to have on the forms

 Click Next

 Choose the sort order for your report

 Choose the layout for the form

 Click Next

 Choose a style

 Click Next

 Create a title

 Choose whether you want to o[pen the form to view it or modify the form’s design
 Click Finish

Class Task

1. What is a form?
2. How would you create a form?
3. State the operations that can be performed in a database.
4. List five (5) data-type.

Ticket-Out

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 package
5. ____ model organizes data using two fundamental constructs, called records and sets. (a)
Hierarchical (b) Relational (c) Network (d) Optical
SUBJECT: DATA PROCESSING
WEEK THREE
DURATION: 45 MINUTES
TOPIC: DATA MODELING 3
INSTRUCTIONAL MATERIALS: CLASSIC COMPUTER STUDIES BOOK 1, TUTORIAL VIDEOS &
PICTURE MATERIALS
OBJECTIVES: at the end of the lesson, learners should be able to:
1. State the significance of data modeling

2. List examples of standard data model

CONTENT

Data models are a great communication tool because it facilitates interaction and
communication between designers, programmers and end users.

A well-developed data model can foster improved understanding of the organization for which
the database design is developed.

Data model help in structuring and organizing data. These data structures are then typically
implemented in a database management system which is used mostly by organizations for
decision making.

Data modeling will impose (implicitly or explicitly) constraints or limitations on the data placed
within the structure.

Standard Data Model

A standard data model or industry standard data model (ISDM) is a model that is widely applied
in some industry, and shared amongst competitors to some degree. They are often defined by
standard bodies, database vendors or operating system vendors. 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.
They enable easier and faster information sharing because heterogeneous organizations have a
standard vocabulary and pre-negotiated semantics, format and quality standards for exchange
data.

Examples of Standard Data Models

1. ISO 10303: this is an ISO standard for the computer-interpretable representation and exchange
of product manufacturing information.
2. ISO 15926: is a standard for data integration, sharing, exchange, and hand-over between
computer systems.
3. IDEAS Group: is the International Defense Enterprise Architecture Simplification for exchange
Group. The deliverable of the project is a data exchange format for military enterprise
architectures.

Class Task

1. Explain the significance of data model.


2. State examples of standard data model

Ticket-Out

1. Use MS Access to create table, form, queries and report for all the classes in your school.
SUBJECT: DATA PROCESSING
WEEK FOUR
DURATION: 45 MINUTES
TOPIC: NORMAL FORMS
INSTRUCTIONAL MATERIALS: CLASSIC COMPUTER STUDIES BOOK 1, TUTORIAL VIDEOS &
PICTURE MATERIALS
OBJECTIVES: at the end of the lesson, learners should be able to:
1. Explain the term normal forms

2. Give examples of tables in normal forms

CONTENT

A database management system is a collection of computer software that enables users to


define, create and maintain a database. Defining a database involves specifying constraints for
the data stored in the database, and normalization is a logical design method which minimizes
duplicate, or redundant, data and design flaws. Normalization is the process of effectively
organizing data in a database. The primary purpose of normalization is to allow update, insert
and delete operations to be performed on a single database table and propagated throughout
the database by means of the defined relationship.

There are two goals of the normalization process:

 Eliminating redundant data ( for example storing the same data in more than one table)

 Ensuring data dependencies make sense (only storing related data in a table)

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.

Types of Normal Form

First Normal Form (1NF)

First Normal Form (1NF) says that all column values must be atomic. 1NF dictates that, for every
row by column position in a given table, there exist only one value, not an array or list of values
i.e. in 1NF, the following rules are observed;

1. Eliminating repeating information


2. Create separate tables for related data.

Second Normal Form (2NF)

The second normal form (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.

NOTE: The 2NF attempts to reduce the amount of redundant data in a table by extracting it,
placing it in new table(s) and creating relationships between those tables.

Third Normal Form (3NF)

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.

The Fourth Normal Form (4NF) and Fifth Normal Form (5NF)

The fourth and the fifth normal form are beyond the scope of this syllabus.
Note: Both the fourth and the fifth normal form still follows the goal of normalization process,
which are;

1. Eliminating redundant data.


2. Ensuring data dependencies make sense.

Class Task

1. Define Normalization.
2. Explain Normal Form.
3. One of the goals of normalization process is ____ (a)Eliminate redundant data (b)
Ensure data independencies (c) Allow Update, insertion and deletion(d) Create tables
4. The primary purpose of normalization is to ____ (a) Eliminate redundant data (b)
Ensure data dependencies (c) Allow Update, insertion and deletion (d) Create tables
5. Differentiate between a common sense and systematic normalization

Ticket-Out

1. State the rules for carrying out first normal form (1NF).
2. State the rules for carrying out second normal form (2NF).
SUBJECT: DATA PROCESSING
WEEK FIVE
DURATION: 45 MINUTES
TOPIC: NORMAL FORMS 2
INSTRUCTIONAL MATERIALS: CLASSIC COMPUTER STUDIES BOOK 1, TUTORIAL VIDEOS &
PICTURE MATERIALS
OBJECTIVES: at the end of the lesson, learners should be able to:
1. Explain the determination of normal forms

2. Differentiate between primary and foreign key.

CONTENT

Explain the Determination of Normal Form

Normalization is a technique for producing a set of suitable relations that support


the data requirements of an enterprise. Characteristics of a suitable set of relations include:

1. The minimal number of attributes necessary to support the data requirements of the enterprise
2. Attributes with a close logical relationship are found in the same relation.
3. Minimal redundancy with each attribute represented only once with the important exception of
attributes that form all or part of foreign keys

KEY: A key is an attribute or field that can be used to identify a record in a database table or file.

The primary Key is a unique attribute that can be used to identify a record in a database table.
For Example, in the student database table above, the attribute that is unique to identify each
record is the Student-ID or Reg. No.

Concepts of Foreign Key

A 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
constraint when you create or modify a table. The foreign key can be used to cross-reference
table. The foreign key identifies a column or set of columns in one (referencing or child) table
that refers to a column or set of column in another (referenced or parent) table. The columns in
the child table must reference the columns of the primary key or other super key in the parent
table.

Ticket-Out

1. Define Key as regards to database.


2. Differentiate between primary key and foreign key
SUBJECT: DATA PROCESSING
WEEK SIX & SEVEN
DURATION: 45 MINUTES
TOPIC: ENTITY-RELATIONSHIP MODEL
INSTRUCTIONAL MATERIALS: CLASSIC COMPUTER STUDIES BOOK 1, TUTORIAL VIDEOS &
PICTURE MATERIALS
OBJECTIVES: at the end of the lesson, learners should be able to:
1. Define entities, attributes, and relationship.

CONTENT

Entity-Relationship is a graphical representation of entities and their relationships to each


other. Entity relationship diagrams (ERDs) illustrate the logical structure of database. Diagrams
created to design these entities and relationships are called entity-relationship diagrams or ER
diagram.

An entity-relationship model describes data in terms of the following:

 Entities

 Relationship between entities

 Attributes of entities
ERM is graphically represented using an entity-relationship diagram (E-R Diagram).

Entity relationship diagram


Entity: An entity is an object that exists and which is distinguishable from other objects. An
entity can be a person, a place, an object, an event, or a concept which an organization wishes
to maintain data. The following are some examples of entities:
Person: STUDENT, EMPLOYEE, CLIENT
Object: COUCH, AIRPLANE, MACHINE
Place: CITY, ROOM, WAREHOUSE
Concept: PROJECT, ACCOUNT, COURSE
An entity type defines a collection of entities that have same attributes. An entity instance is a
single item in this collection. An entity set is a set of entity instances. For example, STUDENT is
an entity type; a student with ID number ISI070 is an entity instance; and a collection of all
students is an entity set.
In E-R diagram, an entity name should be a concise singular noun that captures the unique
characteristics of the entity type. An E-R diagram depicts an entity type using a rectangle with
the name of the entity inside, as shown below.

Attribute: An attribute is a characteristic of an entity type. Some attributes of common entity


types include the following:
STUDENT = {Student ID, Name, Address, Phone, Email, DOB}
ACCOUNT = {Account Number, Account Type, Date Opened, Balance}

E-R diagrams depict an attribute inside an ellipse and connect the ellipse with a line to the
associated entity type. The diagram below indicates some of the possible attributes in an E-R
diagram for the entity STUDENT.

Types of attributes
1. Simple or an atomic attribute, such as City or State, cannot be further divided into smaller
components.
2. Composite attribute can be divided into smaller subparts in which each subpart represents
an independent attribute. Name and Address are the only composite attributes in the diagram
above.
3. Single-valued attribute: most attributes have a single value. For example, a student has only
one date of birth and one identification number.
4. Multi-valued attribute: have more than one value for an entity instance. For example,
student attribute language above, which stores the name of languages a student can speak,
is a multi-valued attribute.
5. Stored attribute is an attribute whose value cannot be derived from the values of other
attributes.
6. Derived attribute: the value of a derived attribute can be determined by analyzing other
attributes. For example in the figure above, Age is a derived attribute because its value can be
derived from the current date and the attribute DateofBirth.
7. A key attribute (or identifier) is a single attribute or a combination of attributes that uniquely
identify an individual instance of an entity type. No two instances within an entity set can have
the same key attribute value. StudentID is the key attribute in the picture above.

Relationship
Entities in an organization do not exist in isolation but are related to each other. Students take
courses and each STUDENT entity is related to the COURSE entity. Faculty members teach
courses and each FACULTY entity is also related to the COURSE entity. Consequently, the
STUDENT entity is related to the FACULTY entity through the COURSE entity. In an E-R diagram,
we represent relationship types with diamond-shaped boxes connected by straight lines to the
rectangles that represent participating entity types. A relationship type is a given name that is
displayed in this diamond-shaped box and typically takes the form of a present tense verb or
verb phrase that describes the relationship. A relationship is an association among several
entities. The figure below is an E-R diagram that shows a relationship between entities
ACCOUNT and CUSTOMER.

Degree of a relationship
The number of entity sets that participate in a relationship is called the degree of relationship.
The 3 most common degrees of relationship are unary (degree 1), binary (degree 2) and ternary
(degree 3).
Unary relationship: A unary relationship exists when there is an association between two
instances of the same entity type. For example, in an organization, an employee will manage
one or more employee.

Binary relationship: A binary relationship exists when there is an association between two
instances of two different entity types. For example, in a secondary school, a binary relationship
exists between a Subject (SUBJECT entity) and a Teacher (TEACHER entity); a teacher teaches
(a) subject.

Ternary Relationship: A ternary relationship exists when there is an association between three
instances of three different entity types. For example, consider a student using certain
equipment for a project. In this case, the STUDENT, PROJECT, and EQUIPMENT entity types
relate to each other with ternary relationships: a student checks out equipment for a project.

Cardinality of a relationship
The cardinality is the number of occurrences in one entity which are associated (or linked) to
the number of occurrences in another entity. For example, if the entity types A and B are
connected by a relationship, then the maximum cardinality represents the maximum number
of instances of entity B that can be associated with any instance of entity A. There are three
types of relationship:
1. One-to-One Relationship: In a one-to-one relationship, at most one instance of entity B can
be associated with a given instance of entity A and vice versa. For example an employee is
assigned a parking space or an employee manages the department.

2. One-to-Many (or many-to-one) Relationship: In a one-to-many relationship, many instances


of entity B can be associated with a given instance of entity A. However, only one instance of
entity A can be associated with a given instance of entity B. For example, many employee works
in a department or a school has many employees.

3. Many-to-Many Relationship: In a many-to-many relationship, many instances of entity A can


be associated with a given instance of entity B, and, likewise, many instances of entity B can be
associated with a given instance of entity A. For example, many employees work on many
projects.

Uses of Entity Relationship Diagram

1. The Entity-Relationship Diagram is used to identify the data that must be captured, stored and
retrieved in order to support the business.
2. The Entity-Relationship Diagram is also used to identify the data required to derive and
generate report on the performance measures that an organization should be monitoring.

Class Task

1. Define the following: (a) Entity, (b) Attribute (c) Relationship.


2. State the uses of entity-relationship diagram.
3. What is Cardinality?
4. Mention and explain three types of relationship with example.
Ticket-Out

Instruction: Choose the correct option from the ones lettered A to D

1. ____ is the unique, distinguishing characteristic of the entity. (a) Entity (b) Relationship (c)
Attribute (d) cardinality
2. Another name for data Element is ____. (a) Attribute (b) Key (c) Entity (d) Relationship
3. ____ are objects or concepts within the data model. (a) Attributes (b) Relationship (c)
Cardinality (d) Entity
4. A roof covering a building will be considered in relationship as? (a) One-to-Many (b) Many-to-
Many (c) One-to-One (d) Many-to-One
5. A pastor preaching to his congregation will be considered in relationship as? (a) One-to-Many
(b) Many-to-Many (c) One-to-One (d) Many-to-One
SUBJECT: DATA PROCESSING
WEEK EIGHT, NINE & TEN
DURATION: 45 MINUTES
TOPIC: RELATIONAL MODEL (Practical)
INSTRUCTIONAL MATERIALS: CLASSIC COMPUTER STUDIES BOOK 1, TUTORIAL VIDEOS &
PICTURE MATERIALS
OBJECTIVES: at the end of the lesson, learners should be able to:
1. Explain how data is represented.

2. Explain how data can be created, modified, manipulated and queried.

3. How to obtain a database design in relational model.

CONTENT
Relational Models
Relational Database Management System (RDBSM) is the basis for SQL (Structured Query
Language), and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL
and Microsoft Access.

A relational model gives a simple way of representing data in form of a two-dimensional table
called relation. Relational model was invented by Edger Codd. The columns or fields in the
table identify the attribute such as surname, last name, age, gender, Admission number etc. A
tuple or row contains all the data of a single instance of the table such as a person named
James Bond. In the relational model, every tuple must have a unique identification or key based
on the data. In the table below, the Admission number is the key that uniquely identifies each
tuple in the relation. Keys are often used to join data from two or more relations based on
matching identification. Another concept used in a relational model is the foreign keys, which
are primary keys in one relation that are kept in another relation to allow for the joining of
data.
Definition of terms
1. Field: is a named column in the relation (table). There are five fields in the student relation
above – Admission number, Surname, Last name, Age, Gender.
2. Tuple: is a record (i.e. a row of data in a relation). All tuples in a relation must be distinct.
3. Domain: is defined as the set of all unique values permitted for an attribute. For example, the
domain of the field Gender as seen in the table above is M and F. Also the domain of the
attribute Surname consist the combination of all possible letters in the alphabet. A domain is
referred to in a relation schema by the domain name and has a set of values.
4. The Degree (also called arity) of a relation is the number of fields in it. The relation above is of
degree 5.
5. The cardinality of a relation is the number of tuples in it. For example, the relation above
contains 6 tuples and hence the cardinality is 6.
6. A relational database is a collection of relations with distinct names that can be linked
together.
7. Relation schema describes the column heads of the table. The schema specifies the relation’s
name, the name of the field (or attribute or column) and the domain of each field. For example
the schema for the Student relation above is given below:
Student(Admission number: integer, Surname: string, last
name: string, Age: integer, Gender: string).

Relational model keys


1. Candidate key: Candidate keys are defined as the minimal set of fields which can uniquely
identify each record in the table. It is an attribute or a set of attributes that can act as a primary
key for a table to uniquely identify each record in that table.
2. Primary key: is any candidate key that is most appropriate to be the main reference key for the
table. It is used to establish relationship with other tables. It must never be null and must be
unique.
3. Foreign key: is generally a primary key of one table that appears as a field in another where the
first table has a relationship with the second. In other words, if we have a table A with a
primary key X that is linked to a table B where X is a field in B, then X is a foreign key in B.
4. Secondary key or alternative key: a table may have one or more choices for the primary key.
Collectively these are known as candidate keys as shown above. One is selected as the primary
key. Those not selected are known as secondary keys or alternative keys.
5. Composite key is combination of two or more columns in a table that can be used to uniquely
identify each row in a table.
What is SQL?
Structured Query Language is a computer language for storing, manipulating and retrieving
data stored in an RDBMS. SQL is a language of database. SQL is an ANSI (American National
Standards Institute), but there are many different versions.
The SQL commands to relate with the RDBMS are CREATE, SELECT, INSERT, UPDATE, DELETE
and DROP. These commands can be classified into groups based on their nature:

 DDL – Data Definition Language: CREATE (forms a new table, a view of a table, or other object
in database. ALTER (modifies an existing database object, such as a table). DROP (deletes an
entire table, a view of a table or other object in the database).
 DML – Data Manipulation Language: INSERT (creates records). UPDATE (modifies records).
DELETE (deletes records).
 DCL – Data Control Language: GRANT (gives a privilege to a user). REVOKE (takes back privileges
granted to users).
 DQL – Data Query Language: SELECT (retrieves certain records from one or more tables)

Creating and Modifying Relation Using SQL


MS-Access, a relational DBMS typically provides a Graphical User Interface (GUI) that allows the
creation of a database and tables that store information about different subject. This can be
achieved using a query language called SQL (Structured Query Language). SQL can do more
than query a database; it can define the structure of the database, modify data in the database
and specify security constraints. A subset of the SQL that is used to define the structure of the
database and the table is called data definition language (DDL). In SQL, a relation is a table.
Creating a database using SQL
The syntax is as follows:
CREATE DATABASE databasename;
The “CREATE DATABASE” is the keyword and “databasename” is the name of the database.
For example assuming we want to create a database for student’s information, then the create
statement would be as follows:
CREATE DATABASE StudentDB;
Note: Use the Commands:
SHOW DATABASES; - to see the list of databases in the DBMS
DROP DATABASE database_name; - to delete a database from a DBMS
Creating relation (Table) using SQL
The syntax is as follows:
CREATE TABLE table_name (
Column1 datatype,
Column 2 datatype,
Column3 datatype,
.....
columnN datatype,
PRIMARY KEY (one or more columns)
);
The “CREATE TABLE” is the keyword that tells the D system what to do table_name is the name
of the table, “PRIMARY KEY” is a keyword that indicate which column listed above is to be used
as the primary key, column1…ColumnN indicates the fields (or column as in a table).
For example, if you want to create a table that stores student information (i.e. student table),
the statements below will achieve that.
CREATE TABLE StudentTbl (
AdmissionNumber CHAR (10),
Surname CHAR (20),
Lastname CHAR(20),
Age INT (2),
Gender CHAR (1),
PRIMARY KEY (AdmissionNumber)
);
Note: To delete a table from a database, use the command:
DROP TABLE table_name; (i.e. DROP TABLE StudentTbl ).

Modifying Relations Using SQL


Inserting tuple into a relation
In order to insert tuples (records) into a table, the INSERT command is used. Here is the syntax:
INSERT INTO Table_name (column1, column2, ….., columnN)
VALUES (value1, value2,…….., valueN);
OR
INSERT INTO table_name (value1, value2, ….., valueN);
For example to insert the first tuple as indicated in the table above, use the following
statements:
INSERT INTO StudentTbl (AdmissionNumber, Surname, Lastname, Age, Gender)
VALUES (1201, ‘James’, ‘Bond’, 15, ‘M’);
OR
INSERT INTO students (1201, ‘James’, ‘Bond’, 15, ‘M’);
Deleting tuple from a relation
To delete a tuple (record) from the table, use the DELETE Command. Here is the syntax:
DELETE FROM tablename
WHERE [condition];
For example, to delete a tuple with surname = James from the relation above, use the following
statement:
DELETE FROM StudentTbl
WHERE surname = ‘James’ ;
The database system deletes the first record with AdmissionNumber = 1201.
Note: The command ‘DELETE FROM students;’ - will delete all tuples (records)in the table.
Updating the content of a relation
The UPDATE query is used to modify the existing records in a table. The syntax is as follows:
UPDATE table_name
SET column1 = value1, column2 = value2, ……, column = valueN
WHERE [condition];
For example, if we want to change the gender of James Bond in the table above (i.e. from M to
F) , use the following statement:
UPDATE StudentTbl
SET Gender = ‘F’
WHERE surname = ‘James’;
The DELETE, INSERT and UPDATE statements above are part of the SQL subset called the Data
Manipulation Language (DML).

Querying Database
You query the database when you are requesting for certain information from the database.
You can include condition that such items you want should meet. The query helps us retrieve
data from the database.
In its simplest form, a query consists of two parts:
· A SELECT list, where the columns to be retrieved are specified
· A FROM clause, where the table or tables to be accessed are specified
Example
The following SQL statement selects the entire rows of data from the StudentTbl:
SELECT * FROM StudentTbl
It is also possible to specify certain columns to be retrieved from the StudentTbl.
Example
SELECT FirsName, LastName, Age FROM StudentTbl
We can structure the query to limit the number of columns of data to be retrieved from the
StudentTable.
Example
SELECT FirstName, LastName, Date
FROM StudentTbl
WHERE Age > 20
Integrity Constraint over Relations
Constraints
Constraints are the rules enforced on data columns in table. These are used to limit the type of
data that can go into a table. This ensures the accuracy and reliability of the data in the
database. Constraints could be column level or table level. Column level constraints are applied
only to one column, whereas table level constraints are applied to the whole table. The
following are commonly used constraints in SQL:
1. Entity Constraints
Entity constraints can be enforced when you create a table and assign certain column of the
table to be the primary key or and when you assign certain column of that table not to accept
NULL values. The PRIMARY key constraint tells the database engine that none of the rows
should have a duplicate value. The NOT NULL constraint ensures that a column cannot have a
NULL value
Examples
CREATE TABLE StudentTbl (
StudentId INT Primary Key,
FirstName Varchar(15) NOT NULL,
LasttName Varchar(15) NOT NULL,
Gender Char(2),
DOB DateTime
);
You can also use the UNIQUES constraint to ensure that all values in a column are different;
that is, no duplicate entries should exist in the table.
CREATE Table StudentData (
StudentId INT Primary Key,
FullName Varchar(50) unique NOT NULL,
Age INT,
RegDate DateTime Default GETDATE()
);
The GetDate function inserts the current date into the table.
2. Domain Integrity
This constraint can be enforced by specifying that certain columns in the table should be of a
particular data type or that it should meet certain conditions. Example below employs two
types of constraints: CHECK and UNIQUE constraints. The CHECK constraint ensures that all
values in a column satisfy certain conditions (i.e. any record to be inserted must have age value
greater than or equal to 10).
Example
CREATE Table StudentData (
StudentId INT Primary Key,
FullName Varchar(50) unique NOT NULL,
Age INT Check(Age > = 10),
RegDate DateTime Default GETDATE()
);
The DEFAULT constraint provides a default value for the date column when no value is
specified.
3. Referential Integrity
Referential Integrity constraint can be enforced using two or more tables. The first table is
called the parent table while any other table or tables will be regarded as the child table(s). The
child table(s) will be used to reference the parent table.
Example
Create the first table called the parent table:
CREATE TABLE Student(
StudentId INT Primary Key,
FirstName Varchar(15) NOT NULL,
LasttName Varchar(15) NOT NULL,
Gender Char(6),
DOB DateTime
);
Create the second table called the child table:
CREATE TABLE Subject(
SubjectId INT Primary Key,
StudentId INT Foreign Key References Student_tbl(StudentId),
SubjectName varchar(15) Unique,
TeacherName varchar(50) Not Null,
Duration DateTime
);
StudentId in the Subject table is a foreign key that “references” StudentId in the Student table
called the parent table. The idea behind this is that a subject cannot exist for a student when
that student is not in the student (parent) table. For example, in order for a student to have a
subject in the Subject table, such student must exist in the Student table.
SUBJECT: DATA PROCESSING
WEEK ELEVEN
DURATION: 45 MINUTES
TOPIC: FILE ORGANIZATION
INSTRUCTIONAL MATERIALS: CLASSIC COMPUTER STUDIES BOOK 1, TUTORIAL VIDEOS &
PICTURE MATERIALS
OBJECTIVES: at the end of the lesson, learners should be able to:
1. Explain the various types of file organization

2. Explain the efficiency of file organization.

CONTENT

A fie is a collection of data usually stored on disk. File organization refers to the logical
relationships among various records that constitute the file, particularly with respect to the
means of identification and access to any specific record.
File organization is used to describe the way in which the records are stored in terms of blocks,
and the blocks are placed on the storage medium. In short, it refers to the way in which data
records are stored or arranged.

Types of file organization


1. Serial (heap) files organization: records are placed in the order in which they are inserted. A
new record is inserted in the last page of the file; if there is insufficient space in the last page, a
new page is added to the file. This makes insertion very efficient but since heap file has no
particular ordering with respect to field values, a linear search must be performed to access
record as thus making it slower as compared to sorted files.
2. Sequential file organization: records are stored in some sort of order (ascending, descending or
alphabetical) based on the unique key field or search key. This method is fast & efficient for
huge amount of data. Sorted file is inefficient as it takes time & space for sorting records. A
sequential file could be stored on a sequential storage device such as magnetic tape and
magnetic disks. To access these records, the computer must read the file in sequence from the
beginning. The first record is read and processed first, then the second record in the file
sequence, and so on.
3. Index Sequential Access Method (ISAM): Records are organized in sequence and an index table
is used to speed up access to the records without requiring a search of an entire file. The
records of the files can be stored in a random sequence but the index table is in a sorted
sequence on the key value. This type of file organization is best suited for situations where both
batch and online processing are to be supported.
4. Direct or Random file organization: In this file organization, records are organized in such a way
that it is possible for the computer to directly locate the key of the desired record without
having to search through a sequence of the record. Direct file organization allows direct access
to individual records stored in any part of the file. These types of files are used in direct access
storage device (DASD) like floppy disk, hard disk and optical disk.

File access
When a file is used, information is read and accessed into computer memory and there are
several ways to access this information of the file. The file accessing methods are:
1. Direct access: the information/data stored on a device can be accessed randomly and
immediately irrespective to the order it was stored. The data with this access method is quicker
than sequential access. This is also known as random access method. For example hard disk,
flash drive etc.
2. Sequential access: the information/data stored on a device is accessed in the exact order in
which it was stored i.e. one record after another e.g. magnetic tape.

Factors to Consider when choosing a File Organization Method


1. Frequency of update

2. File activity

3. File access method

4. Nature of the system

5. Master file medium

Class Task
1. What is file organization?
2. Explain the types of file organization we have
3. What are the factors to consider when choosing a file organization method?

Ticket-Out
1. Go to YouTube and search for videos on file organization methods. Copy out the URL and your
summary of the video.

You might also like