0% found this document useful (0 votes)
64 views

Ss 2 Data Processing First Term E-Note

The document provides a scheme of work for a Data Processing class covering 13 weeks. It outlines topics to be covered each week such as types of data models, normal forms, entity relationship models, and practical SQL work. The first week focuses on defining data models and outlining three common types: conceptual, logical, and physical data models. The conceptual model involves stakeholders, the logical translates this to database structures, and the physical optimizes for performance.

Uploaded by

Jesse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Ss 2 Data Processing First Term E-Note

The document provides a scheme of work for a Data Processing class covering 13 weeks. It outlines topics to be covered each week such as types of data models, normal forms, entity relationship models, and practical SQL work. The first week focuses on defining data models and outlining three common types: conceptual, logical, and physical data models. The conceptual model involves stakeholders, the logical translates this to database structures, and the physical optimizes for performance.

Uploaded by

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

SUBJECT:

DATA PROCESSING
CLASS:
S.S. 2

TERM: FIRST

©Deeper Life High School. 2023

www.deeperlifehighschool.org …leadership with distinction


SCHEME OF WORK

WEEKS TOPICS CONTENT


TYPES OF DATA (a) Definition of Data model
1 MODELS (b) Type of data models

DATA MODELLING (a) Creating Tables, Forms, Queries


2 and Reports
(b) Significance of data model (c)
Examples of standard data models

NORMAL FORMS (a) Examples of Tables in first


normal forms
3 (b) Tables in second and third normal
forms

NORMAL FORMS (c) Problems of table in first normal


form
4 (d) Determinant of normal forms
(e) Foreign keys

ENTITY (a) Entities, attributes and


RELATIONSHIP relationship (b) Additional features
MODEL of entity model
5
RELATIONAL MODEL (a) Creating and modifying relations
using SQL
6 (b) Integrity constraints over
relations.
7 MID-TERM BREAK
RELATIONAL MODEL (c) Enforcing Integrity constraints
8 (d) Querying relational data
PRACTICAL ON SQL a)Create a Table
b)Insert Records into the Table
9 c)Query the Database Table
10 REVISION
11 EXAMINATION
12
13

www.deeperlifehighschool.org …leadership with distinction


WEEK: 1

TOPIC:TYPES OF DATA MODELS

LESSON OBJECTIVES: By the end of this lesson students will be able to:
i. define the data model
ii. state the various types of data model

ENTRY BEHAVIOUR: The students already know what a model is and had seen architectural
models for buildings.
SUB-TOPIC 1: Definition of Data Model
CONTENT

Data Models are fundamental entities to introduce abstraction in a DBMS. Data models define
how data is connected to each other and how they are processed and stored inside the system.
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.

PRACTICE EXERCISE:
Fill in the gap questions
1. _____________ introduces abstraction into DBMS.
2. DBMS stands for_________________
3. Data models define how _______ is connected
4. A data model is an ____________ that organizes elements
5. The examples of DBMS are ____________, ______________ and _____________
Short answer question
1. What is data model?
2. List two importance of data model in database management
3. List any two examples of DBMS
SUB-TOPIC 2:

CONTENT:THREE LEVELS/APPROACHES OF DATA MODEL


The ANSI/SPARC three level architecture
i. Conceptual Data model
ii. Logical Data Model
iii. Physical Data Model

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

2. 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)

www.deeperlifehighschool.org …leadership with distinction


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

PRACTICE EXERCISE:
Fill in the gap questions
1. We have _____________ levels of Data Model
2. The level of data model that present data inform of tables and columns is
__________________
3. ______________ data model involves the stakeholders and data modeler.
4. The data model that translate the keynotes of the business stakeholder and data modeler into
DBMS is called___________________
5. RDBMS stands for _______________________

Short answer questions


1. List the three levels of data model
2. Write short note on Logical Data Model
3. What is enterprise data model?

SUB-TOPIC 3: Types of Data Model

CONTENT
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.
Types of Database Model
i. Flat model: This may not strictly qualify as a data model. The flat (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 values, and all members of a row are assumed to be related to one
another.

ii. Hierarchical model:The hierarchical model is similar to the network model except that links in
the hierarchical model form a tree structure, while the network model allows arbitrary graph.

www.deeperlifehighschool.org …leadership with distinction


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: is a database model 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. The power of the
relational data model lies in its mathematical foundations and a simple user-level paradigm.

v. Object-relational model: Similar to a relational database model, but objects, classes and
inheritance are directly supported in database schemas and in the query language.

vi. Star Schema: The simplest style of data warehouse schema. The star schema consists of a few
"fact tables" (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.

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. There are several notations used for ERMs

Teacher CLASS
Teachers

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

www.deeperlifehighschool.org …leadership with distinction


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.

PRACTICE EXERCISE
Fill in the gaps
1. The _______________ consists of a single, two-dimensional array of data elements
2. In a database data is organized into simple _______________
3. __________ is a database model based on first-order predicate logic
4. ERM stands for _____________________________
5. The simplest style of data warehouse schema ________________

Short answer questions


1. List any three types of data model
2. What is semantic data model
3. What is entity-relationship model

TOPICAL TEST
1. _____ 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. A. Data Model B. Attribute C.
Cardinality D. Associative entity
2. The following are characteristics of a good data model except …… A. redundancy B.
completeness C. data reusability D. elegance
3. Microsoft Access is a ____________ program. A. DOS B. graphic C. database D.
presentation
4. The process of creating a data model for an information system is termed? A. Programming B.
Data analysis C. Database management D. Data modelling
5. In database management system, the term which is used to represent the real world concept
or object is classified as A. entity B. attribute C. relationship D. abstraction
6. The process of creating a data model for an information system is termed? A. Programming B.
Data analysis C. Database management D. Data modelling
7. The technique of organizing data in the database is called database …… A. normalization B.
field C. normal form D. organization
8. What is the purpose of a primary key in a relational database? A) To store large text data B)
To establish relationships between tables C) To uniquely identify rows in a table D) To store
aggregated data
9. Which modeling technique is used to illustrate the flow of data within a system? A) ER
modeling B) UML modeling C) Data warehousing D) Data flow diagramming
10. In a star schema, what does the fact table contain? A) Primary dimension key B) Basic
attributes C) Foreign keys D) Aggregated data

Fill in the gap questions

www.deeperlifehighschool.org …leadership with distinction


1. In a relational database, a primary key uniquely identifies each ____________ in a table.
2. The process of organizing and defining the structure, relationships, and constraints of a
database is known as ________________.
3. In an ER diagram, a(n) ____________ represents an entity type within the system.
4. The ________________ model is used to represent the logical structure of a database in
terms of entities, attributes, and relationships.
5. A ____________ key is used to establish a link between two tables, typically representing a
foreign key in one table and a primary key in another.
6. Normalization is the process of organizing a database to minimize data ____________ and
improve data integrity.
7. The ________________ level of the ANSI-SPARC architecture describes how data is
physically stored on a storage medium.
8. In a star schema, the ____________ table contains the primary dimension key and basic
attributes.
9. A ____________ diagram illustrates the flow of data and processes within a system,
highlighting how data is input, transformed, and output.
10. The process of converting complex, raw data into a simplified and structured format for
analysis is known as ____________.

Essay Questions
1. What is a data model? Explain the different types of data models.
2. (a) i) What is data modeling (ii) State three types of data modeling (b) (i) List three approaches
to data modeling. [ii] Explain any one approach listed in i(b)(i). [WAEC 2018/1].
3. What are the benefits of using a data model?
4. Discuss the challenges of data modeling.
5. Explain the concept of Entity-relationship.
6. Discuss the three levels of data model.

GLOSSARY OF TERMS / KEY WORDS / VOCABULARY:


Attribute: A characteristic of an entity. For example, the name, age, and address of a customer
are all attributes of the customer entity.
Entity: A person, place, thing, or event about which data is collected. For example, a customer,
order, or product are all entities.
Relationship: A connection between two entities. For example, a customer can have many
orders, and an order can have many products.
Data model: A graphical or textual representation of the data entities, attributes, and relationships
in a database.
Logical data model: A data model that represents the data from a business perspective, without
considering the physical implementation of the database.
Data schema: A set of rules that define the structure of a database.
Physical data model: A data model that represents the data from a technical perspective, taking
into account the physical implementation of the database.

PUZZLES / BRAIN TEASER:


Entity-Relationship Diagram (ERD) Challenge
Consider a university system with the following requirements:
• Professors can teach multiple courses.

www.deeperlifehighschool.org …leadership with distinction


• Courses can have multiple students enrolled.
• Professors can advise multiple students for their projects.
• Each student can have only one advisor.
Draw an Entity-Relationship Diagram (ERD) that represents this scenario, including entities,
attributes, relationships, and cardinalities.

INSPIRATIONAL QUOTES: Education cost money, but then so does ignorance.-Clause


Moser

WEEK: 2

TOPIC: DATA MODELLING

LESSON OBJECTIVES: By the end of this lesson students will be able to:
(a) create Tables, Forms, Queries and Reports
(b) discuss the significance of data model
(c) state the examples of standard data models

ENTRY BEHAVIOUR: Students already know how to create HTML forms and understand
how to forms work to populate a database table.
SUB-TOPIC 1:
CONTENT: Creating Tables, Forms, Queries and Reports

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.

Adding tables to a database

1. In the database window, click on tables in the object bar. Double click create table in design view.
Table design view opens.
2. Type a field name on the first empty line of the Field Name column. Then press Tab to move to
the data Type column.
3. When you move to the Data Type column, an arrow appears for a drop down list. Open the Data
Type drop-down list and select field type.
4. In the bottom half of the dialog box, you see Filed Properties for the field type you selected. Make
any changes to Press Tab to move to Description column and type a description of the field.
(Optional)
5. them that you want.
6. If you have more fields to enter, repeat steps 2 through 5

www.deeperlifehighschool.org …leadership with distinction


7. Click the Table Design window’s Close (x) button
8. When you are asked if you want to save your changes to the table, click Yes. The Save As dialog
box appears.
9. Type a name for the table in the Table Name text box, and then click OK

Creating Query
The easiest way to create a query is with the Simple Query wizard, which enable you to select fields
you want to display.
1. Open the database you want to work with and click the Queries tab
2. Double-click Create Query by Using wizard. The first dialog box of the simple query wizard
appears. This dialog box might look familiar, it is similar to the first screen of the Table Wizard
described earlier.
3. Choose the table from which you want to select field from the Table/Queries drop-down list.
4. Click a field name in the Available Fields list: then click the > button to move it to the Selected
Fields list. Repeat to move all the fields you want. Or move them all at once with the >> button.
Then click on Next.
5. Select type of Query whether Detailed (showing every field of the every record) or Summary
(showing selected SUM, AVG, MIN OR MAX of the selected fields) and click on NEXT
6. Enter a title for the Query in the What Title Do You want for your Query? Text box. I will call it
Student’s record.
7. Click Finish to view the query results.

Designing Report
Report wizard offers a good compromise between ease-of use and flexibility. With the Report
Wizard, you can use multiple tables and queries and choose a layout and format for your report.
1. Open the database containing the table or query on which you want to report
2. Click the Reports tab in the Database window.
3. Double click Create Report by using wizard to start the Report wizard.
4. From the Table/Queries drop-down list, select a table or query from which you want to include
fields.
5. Click a field in the Available Fields list, and then click the > button to move it to the Selected
Fields list.
6. If desired, select another table or query from the Table/Queries list and repeat step 5.
7. If you want the records grouped by any of the fields you selected, click the field, and then click the
> button. You can select several grouping levels in order you want then.
8. The wizard asks you what sort order you want to use. If you want sorted records, open the top
drop-down list and select a field by which to sort.
9. In the next dialog box, choose a layout option from the Layout section. When you click an option
button, the sample in the box changes to show your selection.
10.Choose the orientation for your printed report: Portrait (across the narrow edge of the paper) or
Landscape
11. In the next wizard dialog box, choose a report style.
12.You are asked for a report title. Enter one in the Report textbox and click Finish to see your report
in Print Preview.

PRACTICE EXERCISE:

www.deeperlifehighschool.org …leadership with distinction


1. A database ____________ is a structured representation of data in rows and columns, where
each row represents a unique record and each column represents a data attribute.
2. The primary key of a database table ensures that each row has a ____________ value, which
uniquely identifies that row within the table.
3. The process of organizing a database table to minimize data redundancy and improve data
integrity is known as ____________.
4. With the____________ you can use multiple tables and queries and choose a layout and
format for your report.
5. The easiest way to create a query is with the ___________________

SUB-TOPIC 2: Significance of data model


CONTENT

E/R modeling was revolutionary in that – for the first time in data processing – data, not
processes were at the center of both business analysis and system design. The implications were
enormous; data could now become a reusable commodity, which meant that every unique data
element was identified and inventoried once and only once. That provided the ability to track
every person or program using the unique data elements for any purpose.
The concepts of data-driven analysis, and much later of data-driven methodologies, were born as
business analyst and data modeling practitioners realized that they could finally create a business
model of their organization that would logically portray a non-redundant ‘single version of the
truth’ of their enterprise in terms of its data resources. Companies created departments called
data resource management (DRM) and information resource management (IRM) to manage their
business data as a corporate asset, just like they managed their financial asset, fixed asset, real
estate, or human resources.

PRACTICE EXERCISE:
1. __________ modeling was revolutionary
2. Companies created departments called __________________
3. DRM stands for ________________________
4. IRM stands for what _______________________________
5. For the first time in data processing- data, not processes were at the center of both
__________ and ________

SUB-TOPIC 3: Examples of standard data model


CONTENT

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

www.deeperlifehighschool.org …leadership with distinction


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 more effective standard models were 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.

PRACTICE EXERCISE:
1. The most complex data models known are in _____________
2. NATO stands for_______________________
3. _____________ is a data model that is widely applied in some industry, and shared amongst
competitors to some degree.
4. ISDM stands for______________________
5. Data sharing issues may occur is data is out of _______________compliance with standards.

TOPICAL TEST
OBJECTIVE QUESTIONS
The diagram below illustrates the relationship between two tables in a database, Use it to answer
questions 1and2
1. The student ID in Table II is referred to as A. primary key. B. foreign key C. normal key. D.
composite key. [2015/35]
2. What type of relationship exists between Tables I and II? A. One to one. B. Three to four C.
Four to three D. One to many. [2015/36]
3. In a relational database management system, files are organized as relations and A. tuple. B.
modules C. table D. forms. [2015/38]
4. In relational model, a tuple is a A. column of a table. 8. key of a table. C. row of a table. D. two-
dimensional table. [201 6/35]
5. Relationships between tables in a relational model are created by A. foreign keys B.
determinants. C. composite keys. D. candidate keys. [2016/36]
6. Which of the following is used to retrieve specific information from database tables? A. Index.
B. Query. C. Report. D. Table. [2017/34]
7. Which of these methods would delete a relationship defined between two tables in MS Access?
A. Selecting Delete relationship from the Edit menu dialog box. B. Selecting the relationship line
and pressing Delete key. C. Selecting Delete from the relationship menu D. Selecting Delete
relationship from the file drop down menu. [2017/35]
8. What is the purpose of a SELECT query in Microsoft Access?A) To add new records to a table.
B) To update existing records in a table. C) To retrieve and display data from one or more tables.
D) To delete records from a table.
9. What is the purpose of generating a report in Microsoft Access?
A) To create new database tables. B) To modify the structure of existing tables. C) To present
data from tables in a formatted and organized manner. D) To perform complex data calculations.
10. Which feature in Microsoft Access allows you to design and customize the layout of a report?

www.deeperlifehighschool.org …leadership with distinction


A) Form View B) SQL View C) Design View D) Table View
11. What is the purpose of a report wizard in Microsoft Access?
A) To automatically generate complex SQL queries. B) To assist in creating macros for database
automation. C) To guide you through the process of creating a report by asking questions. D) To
create and manage user access permissions.
12. How can you add calculated fields to a report in Microsoft Access?
A) By using VBA (Visual Basic for Applications) code. B) By inserting Excel formulas directly into
the report. C) By creating calculated fields in the underlying query. D) By importing calculated
data from external sources.
13. In Microsoft Access, which section of a report is used to display group-level summaries or
calculations?
A) Page Header/Footer B) Detail Section C) Group Header/Footer D) Report Header/Footer

Fill in the gap questions


1. A database table is a structured collection of ________ organized into rows and columns.
2. A primary key is a column or set of columns in a table that uniquely identifies each ________
in the table.
3. A foreign key is a field in a table that establishes a link to the primary key in another table,
creating a ________ between the two tables.
4. An index in a database table is a data structure that improves the speed of data retrieval
operations by providing a quick way to locate specific ________
5. A database report in Microsoft Access is a formatted presentation of data from one or more
________.
6. The ________ view in Microsoft Access allows you to design the layout and formatting of a
report.
7. A database query in Microsoft Access is a request for specific ________ from one or more
tables
8. The ________ view in Microsoft Access allows you to visually design a query by selecting
fields and criteria.
9. The ________ clause in a query allows you to filter the results based on specific conditions.
10. The most complex data models known are in ___________

GLOSSARY OF TERMS / KEY WORDS / VOCABULARY:


1. Database Table: A structured collection of data organized into rows and columns.
2. Column: A vertical element in a table that represents a specific data attribute.
3. Row/Record: A horizontal element in a table that represents a complete set of data.
4. Primary Key: A unique identifier for each record in a table, ensuring data integrity and enabling
efficient data retrieval.
5. Foreign Key: A field that establishes a link to the primary key in another table, creating a
relationship between tables.
6. Index: A data structure that enhances data retrieval speed by providing quick access to specific
rows.
7. Data Type: Specifies the kind of data that a column can hold, such as text, numbers, dates,
etc.
Database Query:
1. Database Query: A request for specific data from one or more tables based on defined criteria.
2. Criteria: Conditions or rules used to filter, sort, or manipulate data in a query.

www.deeperlifehighschool.org …leadership with distinction


3. SELECT Statement: An SQL command used to retrieve data from a database table.

Database Report:
1. Database Report: A formatted presentation of data from one or more tables, often used
for analysis and communication.
2. Report Wizard: A tool in Microsoft Access that assists in creating reports by guiding
users through a series of steps.
3. Grouping: Organizing data in a report based on specific fields, often used to create
summary sections.
4. Sorting: Arranging data in a report in a specified order, such as ascending or
descending.
5. Report Header/Footer: Sections at the beginning and end of a report where you can
include titles, dates, and other information.
6. Detail Section: The main part of a report where individual records are displayed.
7. Calculated Field: A field in a report that displays calculated values based on
expressions or formulas.
8. Parameter Report: A report that prompts the user for input before generating.
9. Export: The process of saving a report in various formats (PDF, Excel, etc.) for sharing
or archiving.

PUZZLES / BRAIN TEASER:


Composite Primary Key
You are designing a database for a library. Each book can have multiple authors. Each book is
uniquely identified by its ISBN (International Standard Book Number), and each author is identified by
an AuthorID. How would you design the tables to represent this relationship using a composite
primary key?

INSPIRATIONAL QUOTES: “Let us pick up our books and our pens. They are our most powerful
weapons. One child, one teacher, one book and one pen can change the world.”
― Malala Yousafzai

WEEK: 3

TOPIC:NORMAL FORMS

LESSON OBJECTIVES: BY THE END OF THIS LESSON STUDENTS WILL BE ABLE TO:
(a) defines database normalization
(b) resolve tables in first normal forms
(c) Tables in second and third normal forms

ENTRY BEHAVIOUR: The students already had the knowledge of database and can create
database and tables using Microsoft Access.
SUB-TOPIC 1:

www.deeperlifehighschool.org …leadership with distinction


CONTENT: Examples of Tables in first normal forms
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
• UpdationAnamoly : 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.

Normalization Rule
Normalization rule are divided into the following normal form.
1. First Normal Form
2. Second Normal Form
3. Third Normal Form
4. BCNF
PRACTICE EXERCISE:
1. __________ is a systematic approach of decomposing tables to eliminate data redundancy
and undesirable characteristics.
2. Normalization is used for mainly ___________ purposes.
3. It becomes difficult to ________ and ______ the database without facing data loss.
4. Normalization rule are divided into ________, ________, ________ and ___________ normal
form
5. _____________,____________ and _________ are anomalies in database normalization.

SUB-TOPIC 2:
CONTENT: 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
www.deeperlifehighschool.org …leadership with distinction
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. 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.

PRACTICE EXERCISE:
1. In ______________, any row must not have a column in which more than one value is saved.
2. In First Normal Form, no two Rows of data must contain _________ group of information.
3. Each row should have a __________ that distinguishes it as unique.
4. The _________ key is usually a single column.
5. Each table should be organized into ________, and each row should have a _______ key that
distinguishes it as _________.

SUB-TOPIC 3:
CONTENT:Tables in second and third normal forms
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.
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
www.deeperlifehighschool.org …leadership with distinction
Adam 15
Alex 14
Stuart 17
In Student Table the candidate key will be Student column, because all other column i.eAge 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. For example, consider a table with following fields.
Student_Detail Table :
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_Detail Table :
Student_id Student_name DOB Zip
Address Table :
Zip Street city state

The advantage of removing transtive dependency is,


• Amount of data duplication is reduced.
• Data integrity achieved.

BOYCE AND CODD NORMAL FORM (BCNF)


Boyce and Codd Normal Form is a higher version of the Third Normal form. This form deals with
certain type of anamoly that is not handled by 3NF. A 3NF table which does not have multiple
overlapping candidate keys is said to be in BCNF. For a table to be in BCNF, following conditions
must be satisfied:
• R must be in 3rd Normal Form
• and, for each functional dependency ( X -> Y ), X should be a super Key.
www.deeperlifehighschool.org …leadership with distinction
PRACTICE EXERCISE:
1. As per the Second Normal Form there must not be any partial __________ of any column on
primary key.
2. If any column depends only on one part of the concatenated key, then the table fails
_________
3. Third Normal form applies that every non-prime attribute of table must be dependent on
_______
4. In a table, studID can be said to be the ____________________ key
5. ____________ is a higher version of the Third Normal form

TOPICAL TEST
Objective Questions
1. What is database normalization? A) A process of adding redundancy to improve performance.
B) A process of removing redundancy to improve data integrity. C) A process of creating more
tables in a database. D) A process of changing data types in a database.
2. What is the primary goal of normalization? A) Maximizing data redundancy. B) Minimizing data
integrity. C) Minimizing data redundancy. D) Maximizing data integrity.
3. Which normal form eliminates partial dependency? A) First Normal Form (1NF) B) Second
Normal Form (2NF) C) Third Normal Form (3NF) D) Fourth Normal Form (4NF)
4. Which normal form eliminates transitive dependency? A) Second Normal Form (2NF) B) Third
Normal Form (3NF) C) Fourth Normal Form (4NF) D) Fifth Normal Form (5NF)

www.deeperlifehighschool.org …leadership with distinction


5. In which normal form are all attributes functionally dependent only on the primary key? A) First
Normal Form (1NF) B) Second Normal Form (2NF) C) Third Normal Form (3NF) D) Fourth
Normal Form (4NF)
6. What is a candidate key in a relation? A) Any attribute in the relation. B) An attribute that is a
potential primary key. C) A foreign key from another relation. D) An attribute that holds
descriptive data.
7. Which type of dependency does BCNF address? A) Partial dependency B) Transitive
dependency C) Multi-valued dependency D) Functional dependency
8. Which normal form is achieved by satisfying all conditions of 2NF and removing partial
dependencies? A) Second Normal Form (2NF) B) Third Normal Form (3NF) C) Boyce-Codd
Normal Form (BCNF) D) Fourth Normal Form (4NF)
9. What is multi-valued dependency? A) When an attribute depends on a combination of
attributes. B) When an attribute depends on only part of the primary key. C) When an attribute
has multiple values in a single tuple. D) When an attribute is dependent on a foreign key.
10. Which normal form eliminates multi-valued dependency? A) Third Normal Form (3NF) B)
Boyce-Codd Normal Form (BCNF) C) Fourth Normal Form (4NF) D) Fifth Normal Form (5NF)

GLOSSARY OF TERMS / KEY WORDS / VOCABULARY


1. Normalization: The process of organizing and structuring a database to minimize redundancy
and improve data integrity.
2. Database Anomaly: An inconsistency or undesirable characteristic in a database that occurs
due to data redundancy or improper organization.
3. Functional Dependency: A relationship between attributes in a database where one attribute's
value determines another attribute's value.
4. Candidate Key: An attribute (or a set of attributes) in a relation that can uniquely identify each
tuple/record.
5. Primary Key: A candidate key chosen to uniquely identify records in a relation, ensuring each
tuple has a distinct identifier.
6. Partial Dependency: A form of data redundancy where an attribute depends only on a part of
the primary key.
7. Transitive Dependency: A form of data redundancy where an attribute depends on another
attribute that is not a candidate key.
8. First Normal Form (1NF): Ensures that each attribute within a relation contains only atomic
(indivisible) values.
9. Second Normal Form (2NF): Builds upon 1NF and eliminates partial dependencies by ensuring
that non-key attributes are fully functionally dependent on the entire primary key.
10. Third Normal Form (3NF): Builds upon 2NF and eliminates transitive dependencies by
ensuring that non-key attributes are not dependent on other non-key attributes.
11. Boyce-Codd Normal Form (BCNF): A stronger version of 3NF that ensures that every non-
trivial functional dependency in a relation is determined by a superkey.
ESSAY
1. Explain the concept of normalization in database design.
2. Discuss the primary objectives of normalization and how it contributes to improving the quality,
efficiency, and maintainability of a database schema.
3. Provide examples of real-world scenarios where normalization helps prevent data anomalies
and redundancies.
4. Describe the process of achieving First Normal Form (1NF) in a relational database.

www.deeperlifehighschool.org …leadership with distinction


5. Provide a step-by-step explanation of the transformation required to convert a table with
repeating groups and atomicity violations into a 1NF-compliant table.
6. Highlight the significance of 1NF in maintaining data integrity.

PUZZLES / BRAIN TEASER:Normalization Dilemma


You are given a denormalized table that contains information about customers and their orders.
The table has the following columns: CustomerID, CustomerName, CustomerAddress, OrderID,
OrderDate, ProductName, Quantity.
Is this table in a normalized form? If not, describe the normalization issues present, and propose
how you would transform this table into a normalized schema.

INSPIRATIONAL QUOTES: “A teacher affects eternity; he can never tell where his influence stops.”
-Henry B. Adams

WEEK: 4

TOPIC:NORMAL FORMS

LESSON OBJECTIVES: BY THE END OF THIS LESSON STUDENTS WILL BE ABLE TO:
(a) state the problems of table in first normal form
(a) discuss determinant of normal forms
(c) discuss the foreign keys

ENTRY BEHAVIOUR: The students already understand how to resolve a table into first normal
form.

SUB-TOPIC 1:
CONTENT: Problems of table in first normal form
Tables that do not conform to the rules of First Normal Form (1NF) can suffer from a variety of
problems that can lead to data inconsistencies, anomalies, and difficulties in data manipulation.
Here are some problems associated with tables that are not in 1NF:

1. Repeating Groups:
Tables not in 1NF may contain repeating groups, where a single field might hold multiple values.
This can make it challenging to query, update, and maintain the data accurately. Repeating
groups can also lead to data redundancy and inefficiencies in storage.

2. Inconsistent Data Entry:


Without proper atomicity, data may be entered inconsistently. For instance, if a table has a single
column for "Phone Numbers," a user might input multiple phone numbers separated by commas,

www.deeperlifehighschool.org …leadership with distinction


leading to variations in data formatting and making it difficult to query or retrieve specific phone
numbers.

3. Difficulty in Querying:
Lack of atomicity in attributes can complicate querying. If a field holds a list of values, extracting
specific information becomes complicated and may require more complex queries or
transformations.

4. Update Anomalies:
Updating a value within a repeating group might lead to inconsistencies if not all occurrences of
that value are updated simultaneously. This can result in data integrity issues where different
parts of the database contain contradictory information.

5. Deletion Anomalies:
Deleting a row from a table with repeating groups can result in loss of information that is related
to other parts of the data. This can lead to unexpected data loss and affect the overall accuracy of
the dataset.

6. Limited Sorting and Indexing:


Repeating groups make it challenging to sort and index data effectively. Traditional sorting and
indexing techniques work best with atomic attributes, and not conforming to 1NF can hinder
performance when searching or retrieving data.

7. Limited Constraints and Validation:


Applying constraints and validation rules to individual values within a repeating group can be
complex and error-prone. This can result in inaccurate data and lack of data integrity checks.

8. Complicated Data Entry:


Entering data into tables with repeating groups can be cumbersome, as users may need to deal
with lists of values rather than entering individual pieces of information.

In summary, tables that do not adhere to the rules of First Normal Form can suffer from a range of
problems that affect data consistency, accuracy, and ease of manipulation. It's essential to
structure data in a way that conforms to 1NF to avoid these issues and provide a solid foundation
for further normalization and optimization.

Instance and scenario


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 Employee Dept.


Number Name Number
01287 Clark 05
22617 Walsh 05
70964 Smith 12
www.deeperlifehighschool.org50607 Black 05 …leadership with distinction
Department Table
Dept. Num Dept. Name Dept. Locat.

05 Auditing HQ
12 Legal MS

Qualification Table
Employee Quali. Quali. Year
Number Descri.
01287 Bachelor of Art 1970
22617 Master of Art 1973
70964 Doc. Philio 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.

PRACTICE EXERCISE:
1. Tables not in 1NF may contain ________ groups, where a single field might hold _______
values.
2. Applying constraints and ________ rules to individual values within a repeating group can be
complex and error-prone.
3. Repeating groups make it challenging to sort and _________ data effectively.
4. Lack of atomicity in ___________ can complicate querying.
5. Entering data into tables with repeating groups can be _________, as users may need to deal
with lists of values rather than entering individual pieces of information.

SUB-TOPIC 2:

CONTENT:Determinants of Normal Forms


Determinants of Normal Forms, also known as functional dependencies, are essential concepts in
the field of database normalization. These determine the conditions under which a database table
is considered well-structured and avoids redundancy and anomalies. Here's a brief overview of
each normal form and their determinants:

First Normal Form (1NF):


A table is in 1NF if it has no repeating groups and all its attributes hold only atomic (indivisible)
values. The determinant for 1NF is the primary key of the table.

Second Normal Form (2NF):


A table is in 2NF if it is in 1NF and every non-prime attribute (attribute not part of the primary key)
is fully functionally dependent on the entire primary key. The determinant for 2NF is the
combination of the primary key attributes.

www.deeperlifehighschool.org …leadership with distinction


Third Normal Form (3NF):
A table is in 3NF if it is in 2NF and every non-prime attribute is non-transitively dependent on the
primary key. In other words, there should be no transitive dependencies among non-prime
attributes. The determinant for 3NF is the primary key along with attributes that are directly
dependent on it.

Boyce-Codd Normal Form (BCNF):


A table is in BCNF if, for every non-trivial functional dependency (X -> Y), X is a superkey. This
means that no partial dependency exists. The determinant for BCNF is any candidate key of the
table.

Fourth Normal Form (4NF):


A table is in 4NF if it is in BCNF and it has no multi-valued dependencies. A multi-valued
dependency occurs when a value in one attribute uniquely determines a set of values in another
attribute. The determinant for 4NF is the combination of attributes in a multi-valued dependency.

PRACTICE EXERCISE:
Question 1:
A table is said to be in First Normal Form (1NF) when it contains no repeating groups and all
attributes hold only __________ values.
Question 2:
In the context of Second Normal Form (2NF), an attribute is considered fully functionally
dependent on the primary key if it depends on the entire __________.
Question 3:
Boyce-Codd Normal Form (BCNF) requires that for every non-trivial functional dependency, the
determinant (X) must be a __________.
Question 4:
A table is in Fourth Normal Form (4NF) if it is in BCNF and has no __________ dependencies.
Question 5:
Fifth Normal Form (5NF), also known as Project-Join Normal Form (PJNF), ensures that a table
has no __________ dependencies, where a table can be reconstructed by joining other tables.

SUB-TOPIC 3:

CONTENT:Primary Keys
A primary key 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?”

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

www.deeperlifehighschool.org …leadership with distinction


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.

PRACTICE EXERCISE:
1. A primary key is a ________ column or combination of columns that has a different value for
every row in the table.
2. Sometimes more than one column or combination of columns could serve as a _________
key.
3. Cross-referencing columns are called _________ keys.
4. Primary keys, whether chosen or not, is called ____________ keys
5. In moving from first to third normal form, we left determinants behind as _________ to the
relevant rows in the new tables.

TOPICAL TEST:
Objective questions
1. Tables not in First Normal Form (1NF) often suffer from: a) Efficient data storage b) Reduced
data redundancy c) Repeating groups d) Simplified data manipulation
2. Which of the following is a characteristic of tables in violation of 1NF? a) Each field holds a
single, atomic value b) Data entry is consistent and standardized c) Data is easily searchable
and sortable d) Repeating groups of data exist within a field
3. A repeating group in a table refers to: a) A group of fields that are always repeated in every
row b) A field that contains multiple values in a single instance c) A set of related tables with
duplicated data d) A data entry error that needs to be corrected
4. Data redundancy in tables not in 1NF can lead to: a) Improved data integrity b) Faster query
performance c) Inconsistencies and inaccuracies d) Smaller database size
5. Updating a value in a repeating group without updating all instances of that value can result in:
a) Data consistency b) Data accuracy c) Update anomalies d) Improved query performance
6. Which of the following is a challenge posed by tables not conforming to 1NF? a) Easier data
entry b) More flexible data types c) Difficulty in applying constraints d) Reduced storage
requirements
7. Tables with repeating groups are problematic for indexing and sorting due to: a) The presence
of atomic values b) The lack of primary keys c) The complexity of data types d) Their non-
atomic nature
8. In tables not in 1NF, deleting a row can lead to: a) Improved data integrity b) Data
redundancy c) Deletion anomalies d) Simplified data maintenance

www.deeperlifehighschool.org …leadership with distinction


9. Applying constraints and validation rules to individual values within a repeating group can be
challenging, leading to: a) Improved data quality b) Data consistency c) Data anomalies d)
Efficient query performance
10. The primary goal of converting tables into First Normal Form is to: a) Increase data
redundancy b) Simplify data entry c) Prevent data anomalies and inconsistencies d) Improve
query complexity

Fill in the gap Questions


1. A table is said to be in First Normal Form (1NF) when it contains no repeating groups and all
attributes hold only __________ values.
2. In the context of Second Normal Form (2NF), an attribute is considered fully functionally
dependent on the primary key if it depends on the entire _________
3. Boyce-Codd Normal Form (BCNF) requires that for every non-trivial functional dependency,
the determinant (X) must be a __________.
4. Tables not in 1NF may contain ________ groups, where a single field might hold _______
values.
5. Applying constraints and ________ rules to individual values within a repeating group can be
complex and error-prone.
6. Repeating groups make it challenging to sort and _________ data effectively.
7. Lack of atomicity in ___________ can complicate querying.
8. Entering data into tables with repeating groups can be _________, as users may need to deal
with lists of values rather than entering individual pieces of information.
9. A primary key is a ________ column or combination of columns that has a different value for
every row in the table.
10. Sometimes more than one column or combination of columns could serve as a _________
key.

ESSAY
1. Discuss the significance of determinants in achieving First Normal Form (1NF) in a relational
database.
2. Explain how non-atomic attributes and repeating groups violate the atomicity principle, and
how functional dependencies help transform a table into 1NF.
3. Illustrate this with real-world examples to highlight the importance of atomicity.
4. Define what a determinant is and how it influences the relationships between attributes within a
table.
5. Explain the concept of partial and transitive dependencies, and how identifying determinants
helps address these issues.

GLOSSARY OF TERMS / KEY WORDS / VOCABULARY


1. Fourth Normal Form (4NF): Addresses multi-valued dependencies by splitting a relation
into multiple relations, each with a distinct primary key.
2. Fifth Normal Form (5NF): Also known as Project-Join Normal Form (PJNF), addresses join
dependencies by decomposing relations into smaller ones.

www.deeperlifehighschool.org …leadership with distinction


3. Multi-valued Dependency: A form of data redundancy where an attribute depends on
multiple, independent values within a single record.
4. Denormalization: The deliberate introduction of controlled redundancy in a database for
performance optimization or simplification.
5. Join Dependency: A situation where a relation's attributes can only be determined by
considering multiple relations together.
6. Normalization Anomaly: A problem that arises when certain types of updates or insertions
result in unexpected or incorrect data due to improper normalization.
7. Dependent: An attribute that relies on another attribute for its value.
8. Dependent Attributes: Attributes that are determined by other attributes in a database.
9. Redundancy: The presence of duplicate data in a database, leading to wasted storage
space and potential data inconsistencies.
10. Composite Key: A primary key composed of multiple attributes to uniquely identify a record.
11. Functional Dependency Diagram: A graphical representation of the functional
dependencies within a relation.

PUZZLES / BRAIN TEASER: Determining Normal Form


Consider a table that stores information about students and their courses. The table has the
following attributes: StudentID, StudentName, CourseCode, CourseName, ProfessorID,
ProfessorName. Assume that each student can enroll in multiple courses, and each professor can
teach multiple courses.
Determine the functional dependencies present in this table and identify the normal form that this
table currently satisfies. Additionally, propose any necessary modifications or decompositions to
bring the table to a higher normal form.
Feel free to identify the functional dependencies and determine the normal form based on the
given information. If you need hints or want to discuss the solution, I'm here to help!

INSPIRATIONAL QUOTES: “A teacher affects eternity; he can never tell where his influence stops.”
-Henry B. Adams

WEEK: 5

TOPIC:ENTITY RELATIONSHIP MODEL

LESSON OBJECTIVES: BY THE END OF THIS LESSON STUDENTS WILL BE ABLE TO:
(a) discuss entities, attributes and relationship
(b) state the additional features of entity model

ENTRY BEHAVIOUR: This students understand what it is to have relationship with their family
members.

SUB-TOPIC 1:

CONTENT:Entities, attributes and relationship

www.deeperlifehighschool.org …leadership with distinction


PRODUCT Entity
ProductID

Unit price

Qty on hand Supplied


by
Cardinality

Attributes
Name
SUPPLIER
Relationship
Addres
s

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

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
www.deeperlifehighschool.org …leadership with distinction
PRACTICE EXERCISE:
1. ____________ are properties or characteristics of a particular entity about which we wish to
collect and store data.
2. Each of your customers may have a unique customer ID. Such attributes are known as
__________
3. A relationship between entities is drawn as a line bisected by a ______________
4. Entities are drawn as __________ boxes containing a noun in singular form.
5. The rectangle are called _______ type and the ovals are called _____________
SUB-TOPIC 2:
CONTENT: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 in 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

PRACTICE EXERCISE:
1. ERD stands for ____________________
2. To transform a relationship into an entity in an ERD, we use a special symbol called
an____________
3. The notation for an associative entity is a relationship _______ nested inside of an entity
rectangle.
4. It makes sense to treat the _________ as an entity in its own right.
5. The oval in the ERD diagram is ___________________

TOPICAL TEST
In the context of a relational database, what does an "entity" represent?
A) A specific instance of a database table. B) A collection of attributes describing a real-world
object or concept. C) A query used to retrieve data from multiple tables. D) A foreign key linking
two tables together.
1. Which of the following statements about entities is true?
A) Entities are only used in object-oriented programming. B) Entities are not related to the
structure of a database. C) Entities have attributes that describe their properties. D) Entities are
used exclusively for visual design purposes.

www.deeperlifehighschool.org …leadership with distinction


2. An entity is typically represented as a ________ in an Entity-Relationship Diagram (ERD).
A) Circle B) Rectangle C) Triangle D) Line
3. In an ERD, what is the purpose of a "relationship" between entities?
A) It indicates a primary key. B) It represents a foreign key. C) It describes the attributes of an
entity. D) It shows how entities are related or connected.
4. In the context of a relational database, which term refers to a property or characteristic of an
entity?
A) Relationship B) Key C) Attribute D) Normalization
6. In a relational database, what is an "attribute"?
A) A foreign key linking two tables. B) A record that contains data about a specific entity. C) A
column that represents a specific property or characteristic of an entity. D) A visual representation
of a relationship between entities.
7. Which of the following is an example of an attribute for a "Person" entity?
Email Address B) Order Number C) Product Price D) Invoice Date
8. How are attributes usually represented in a database table?
A) As rows in the table. B) As separate tables. C) As columns in the table. D) As relationships
between tables.
9. Which of the following data types could an attribute "Age" have in a database?
A) VARCHAR B) FLOAT C) DATE D) INTEGER
10. In an Entity-Relationship Diagram (ERD), attributes are typically shown inside:
A) Circles B) Triangles C) Rectangles D) Diamonds
Fill in the gap question
1. An attribute is a characteristic or property that describes a specific ____________.
2. In a relational database, an attribute is represented by a ____________ in a table.
3. The data type of an attribute defines the kind of ____________ that can be stored in that
attribute.
4. A primary key attribute uniquely identifies each ____________ in a database table.
5. An attribute that can have multiple values for a single entity is known as a ____________
attribute.
6. In a database, an ____________ represents a person, place, object, event, or concept that
can be uniquely identified and stored.
7. An Entity-Relationship Diagram (ERD) is a graphical representation used to depict the
____________ and relationships within a database.
8. A relationship in a database is an association between ____________ that describes how they
are related to each other.
9. A ____________ key is a field in one entity that matches the primary key of another entity and
establishes a connection between them.
10. A one-to-many relationship between entities means that one entity instance is associated with
____________ instances of another entity.

GLOSSARY OF TERMS / KEY WORDS / VOCABULARY:


1. Relationship: A logical connection or association between entities that describes how they are
related.
2. One-to-One Relationship: A relationship where each entity instance in one entity corresponds
to exactly one entity instance in another entity.

www.deeperlifehighschool.org …leadership with distinction


3. One-to-Many Relationship: A relationship where an entity instance in one entity is related to
multiple instances in another entity, but each instance in the second entity is related to only
one instance in the first entity.
4. Many-to-Many Relationship: A relationship where multiple instances in one entity can be
associated with multiple instances in another entity. This is typically resolved using an
intermediary table.
5. Foreign Key: An attribute in one table that refers to the primary key of another table, creating a
connection between the two tables.
8. Entity: A distinct object, person, place, concept, or event in the real world that can be uniquely
identified and described.
9. Attribute: A property or characteristic of an entity that holds data values.
10. Primary Key: An attribute (or set of attributes) that uniquely identifies each instance of an
entity.
15. Null Value: A value that represents the absence of data or an unknown value.
16. Key Attribute: An attribute used to uniquely identify an entity instance.
17. Superkey: A set of one or more attributes that can uniquely identify an entity instance.
18. Unique Key: A set of attributes that ensures uniqueness but may not serve as the primary key.

PUZZLES / BRAIN TEASER:ENTITY RELATIONSHIPS


Consider a university database. You have entities for Students, Courses, and Professors.
Students enroll in Courses, and Professors teach Courses. Draw an ER diagram that represents
this scenario, including entity types, attributes, and relationships.

INSPIRATIONAL QUOTES: Education is the most powerful weapon which you can use to change the
world.”
-Nelson Mandela

WEEK: 6
TOPIC:RELATIONAL MODEL

LESSON OBJECTIVES: BY THE END OF THIS LESSON STUDENTS WILL BE ABLE TO:
(a) create and modifying relations using SQL
(b) Integrity constraints over relations.

ENTRY BEHAVIOUR: The students have conversant with Microsoft access and tables.

SUB-TOPIC 1:

CONTENT: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.

www.deeperlifehighschool.org …leadership with distinction


Activity Activity
Code code
23 Patching
Activity Date
24 Overlay Code Route No
25 Crack 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

www.deeperlifehighschool.org …leadership with distinction


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:
www.deeperlifehighschool.org …leadership with distinction
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.
4. Type the following SQL statement:
5. CREATE TABLE student (student_id int(10), FirstName varchar(40), LastName varchar(40),
Age int(10), Class varchar(40), Scores int(5))
6. 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
www.deeperlifehighschool.org …leadership with distinction
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.

PRACTICE EXERCISE:
1. The relational model for ______________ predicate logic
2. Examples of Operators are ____________, ____________ and _________________
3. ______________ is the part of SQL that permits creating and deleting of Databases and
database tables.
4. _____________ is the part that supports query and update commands
5. The SQL __________ is used for creating database and tables

SUB-TOPIC 2:
CONTENT: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[, ...]]) |

www.deeperlifehighschool.org …leadership with distinction


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}]}

PRACTICE EXERCISE:
1. A ________ establishes a logical condition that a field or combination of fields must meet
when values are inserted.
2. A ___________ is a type of constraint that refers to the values of a field.
3. To create a constraint, you use a CONSTRAINT clause in a ________________ command.
4. A ____________ CONSTRAINT clause immediately follows the definition of the field that it
constrains
5. A ____________ CONSTRAINT clause can be used only outside a field-definition clause

TOPICAL TEST:
1. Which of the following sets are available when creating a table in “Design View” in Microsoft
Access? A. Data Type, Description and Field Name B. Description, Criteria and Field Property
C. Field Name, Data type and Field PropertyD. Criteria, Field Name and Description [2019/23]
2. A database contains list of customers and their phone numbers. What type of relationship
describes a customer having multiple phone numbers? A. Many-to-many B. Many-to-one C.
One- to-many D. One-to-one [2020/22]
3. Table Marksheet
ID NAME SCORE GRADE
001 ABDUL 55 C
002 EMEKA 52 C
003 KOLA 49 P
The DBMS statement, Select* from Marksheet in table Marksheet will display all records in the
fields: A. ID and Name only. B. ID, Score and Grade only. C. Score and Grade only. D. ID,
Name, Score and Grade. [2020/231
4. Which of the following database operations does not require a Data Manipulation Language?
A. Modification of information B. Insertion of new information C. Deletion of information D.
Creation information [2020/36]
5. Providing access control to a school record is the responsibility of a A. database administrator.
B. programmer. C. systems administrator. D. system analyst. [2020/39]
6. The database tool that allows the user to select and filter data from multiple tables is referred
to as A. form. B. query C. report. D. table [2022/22]
7. What is the fundamental building block of the relational model? A) Row B) Column C) Table D)
Database
8. In the relational model, a table is also known as a ____________. A) Schema B) Entity C)
Record D) Relation
9. Which of the following terms is used to describe the intersection of a row and a column in a
table? A) Cell B) Tuple C) Attribute D) Instance

www.deeperlifehighschool.org …leadership with distinction


10. What does a primary key uniquely identify within a table? A) An attribute B) A column C) A
record D) A database
Fill in the gap questions:
1. SQL stands for ____________ Query Language.
2. The basic unit of data storage in a relational database is a ____________.
3. In SQL, the ____________ statement is used to insert new records into a table.
4. A ____________ is a set of rules that ensures the consistency and integrity of data in a
database.
5. The ____________ clause is used in SQL to specify the conditions for retrieving data from a
table.
6. The SQL ____________ statement is used to modify existing records in a table.
7. The ____________ key is a primary key from one table that is used in another table to
establish a relationship between them.
8. In SQL, the ____________ statement is used to delete records from a table.
9. The SQL ____________ clause is used to filter the results of a query based on a condition.
10. A ____________ is an attribute that can hold multiple values for a single record.

Essay
1. (a). A general hospital decides to computerize the records in all its departments. (i).State one
database management system that can be used for this project.[2014/4]
2. (a) Define the following: (i) Database: (ii) Database Management system. (iii) Mention three
functions of a database management system (b) State three precautionary measures to prevent
data loss [WAEC 2015/2]
3. Outline the steps involved in creating the Query By Example (QBE) in figure 1 assuming the
table customer exists already.

Figure 1 (b) Write the steps to generate the ISQL statement for the action in 4 (a) [WAEC
2018/4]
4. (a) Explain the following database management terms: (I) entities; (ii) attributes; (iii)
relationships. (b)(i) Define cardinality in database management. (iii) Mention three cardinality
relationships in database management. [WAEC 2019/4]
5. A medium scale enterprise intends to create a database to manage its staff records with the
following fields: Staff ID, Name, Address, Photograph and Department.
(a) (i) What is a database? (ii) List three DBMS the firm can use to achieve the stated
objectives. [WAEC 2022/21]

www.deeperlifehighschool.org …leadership with distinction


GLOSSARY OF TERMS / KEY WORDS / VOCABULARY:
1. SQL (Structured Query Language): A standardized programming language used for
managing and manipulating relational databases.
2. Index: A database structure that improves the speed of data retrieval by providing a quick
access path to specific rows.
3. Query: A request for data retrieval or manipulation using SQL statements.
4. Statement: A single line of SQL code that performs a specific action, such as querying,
inserting, updating, or deleting data.
5. SELECT Statement: An SQL statement used to retrieve data from one or more tables.
6. INSERT Statement: An SQL statement used to add new records to a table.
7. UPDATE Statement: An SQL statement used to modify existing records in a table.
8. DELETE Statement: An SQL statement used to remove records from a table.

PUZZLES / BRAIN TEASER:

INSPIRATIONAL QUOTES: “Tell me and I’ll forget; show me and I may remember; involve me and I’ll
understand.”
-Chinese Proverb

WEEK: 8

TOPIC:RELATIONAL MODEL

LESSON OBJECTIVES: BY THE END OF THIS LESSON STUDENTS WILL BE ABLE TO:
(a) enforce Integrity constraints
(b) query relational data

ENTRY BEHAVIOUR:The students have conversant with Microsoft access and tables, and can
as well deal with constrains in database tables.
SUB-TOPIC 1:

CONTENT:Enforcing integrity constraints


We will consider the following constraints:
Constraints Meaning
NOT NULL Enforces a column not to accept NULL
values, that is the field cannot be
empty.
UNIQUE KEY Prevents duplicate data
PRIMARY KEY This constraint uniquely identifies each
record in a database table. It always
carries a unique value
FOREIGN KEY This enforces a constraint that
prevents actions that would destroy
links between tables, and prevents
www.deeperlifehighschool.org …leadership with distinction
invalid data being inserted.
CHECK If you define a CHECK constraint on
a single column it allows only certain
values for this column. If
you define a CHECK constraint on a
table it can limit the values in certain
columns based on values in other
columns in the row.
DEFAULT allow you to specify a value that
the database will use to populate
fields that are left blank in the input
source.
6. SQL NOT NULL Constraint:
The following SQL enforces student_id and Firstname column to not accept NULL values:
CREATE TABLE student
(
Student_id int NOT NULL,
FirstName varchar(255) NOT NULL,
LastName,
Age,
Class,
Scores
)
7. SQL UNIQUE KEY Constraint:
The following SQL enforces gsm_no column not to accept duplicate values on the teachers table
below. Meaning two teachers cannot be sharing one gsm_no
CREATE TABLE teachers
(
teacher_id int NOT NULL,
FirstName varchar(255) NOT NULL,
LastName,
Age,
email_address,
gsm_no int(11) UNIQUE KEY
)
8. SQL PRIMARY KEY Constraint:
The following SQL constraint uniquely identifies each record in a database table. It must contain
unique values. Each table should have a primary key and cannot be NULL. In most cases, the id
is used as the primary key so we will enforce it on the teacher_id in the SQL syntax below.

CREATE TABLE teachers


(
teacher_id int NOT NULL PRIMARY KEY,
FirstName varchar(255) NOT NULL,
LastName,
Age,
www.deeperlifehighschool.org …leadership with distinction
email_address,
gsm_no int(11) UNIQUE KEY
)
1. SQL FOREIGN KEY Constraint:
The FOREIGN KEY in one table points to a PRIMARY KEY in another table. Let us use a student
and teachers table to illustrate this
Student_id FirstName Lastname Age Class Scores
1 John Hassan 15 ss1 20
2 Mary Adebayo 14 ss1 18
3 Agwu Ifeoluwa 16 ss2 21

Sub_id subject Student_id


1 ICT 2
2 Geography 1
3 Chemistry 2
4 Yoruba 3
CREATE TABLE subject
(
teacher_id int NOT NULL,
FirstName varchar(255) NOT NULL,
LastName,
Age,
email_address,
gsm_no int(11) UNIQUE KEY
)

PRACTICE EXERCISE:
1. _______________ enforces a column not to accept NULL values
2. The constraint uniquely identifies each record in a database table is ________________
3. The ____________ in one table points to a PRIMARY KEY in another table.
4. _______, _________, _______ and __________ are unique key that can be used as primary
key like stdID
5. ________, _______, and _________ are examples of data type admissible in SQL

SUB-TOPIC 2:
CONTENT:QUERYING RELATIONAL DATA
Definition: Queries are the primary mechanism for retrieving information from a database and
consist of questions presented to the database in a predefined format. Many database
management systems use the Structured Query Language (SQL) standard query format.
There are various SQL query statements which we will look at briefly and what they are
meant for.

Fetching Data: SQL SELECT Queries


It is a rare database application that doesn't spend much of its time fetching and displaying data.
Once we have data in the database, we want to "slice and dice" it every which way. That is, we
want to look at the data and analyze it in an endless number of different ways, constantly varying
www.deeperlifehighschool.org …leadership with distinction
the filtering, sorting, and calculations that we apply to the raw data. The SQL SELECT statement
is what we use to choose, or select, the data that we want returned from the database to our
application. It is the language we use to formulate our question, or query, that we want answered
by the database. We can start out with very simple queries, but the SELECT statement has many
different options and extensions, which provide the great flexibility that we may ultimately need.
Our goal is to help you understand the structure and most common elements of
a SELECT statement, so that later you will be able to understand the many options and nuances
and apply them to your specific needs. We'll start with the bare minimum and slowly add options
for greater functionality.

A SQL SELECT statement can be broken down into numerous elements, each beginning with a
keyword. Although it is not necessary, common convention is to write these keywords in all capital
letters. We will focus on the most fundamental and common elements of a SELECT statement,
namely
• SELECT
• FROM
• WHERE
• ORDER BY
The SELECT ... FROM Clause
The most basic SELECT statement has only 2 parts: (1) what columns you want to return and (2)
what table(s) those columns come from.
If we want to retrieve all of the information about all of the students in the student table, we could
use the asterisk (*) as a shortcut for all of the columns, and our query looks like
SELECT * FROM student

If we want only specific columns (as is usually the case), we can/should explicitly specify them in
a comma-separated list, as in; using the student table in the example we had in the previous
section, run the query below:

SELECT student_id, FirstName, LastName, Class FROM student


Result
Student_id FirstName Lastname Class
1 John Hassan ss1
2 Mary Adebayo ss1
3 Agwu Ifeoluwa ss2
Explicitly specifying the desired fields also allows us to control the order in which the fields are
returned, so that if we wanted the last name to appear before the first name, we could write it this
way:
SELECT student_id, LastName, FirstName, Class FROM student

And the result will be:


Student_id LastName Firstname Class
1 John Hassan ss1
2 Mary Adebayo ss1
3 Agwu Ifeoluwa ss2

The WHERE Clause


www.deeperlifehighschool.org …leadership with distinction
The next thing we want to do is to start limiting, or filtering, the data we fetch from the database.
By adding a WHERE clause to the SELECT statement, we add one (or more) conditions that
must be met by the selected data. This will limit the number of rows that answer the query and
are fetched. In many cases, this is where most of the "action" of a query takes place.

We can continue with our previous query, and limit it to only those students in ss1:

SELECT student_id, FirstName, LastName, Class FROM student

WHERE Class= 'ss1'

This query will return the following result:


Student_id FirstName Lastname Class
1 John Hassan ss1
2 Mary Adebayo ss1

Only students in ss1 will be echoed. If you want to get other classes you declare it in the
query and the result will be displayed.

The ORDER BY Clause


Until now, we have been discussing filtering the data: that is, defining the conditions that
determine which rows will be included in the final set of rows to be fetched and returned from the
database. Once we have determined which columns and rows will be included in the results of
our SELECT query, we may want to control the order in which the rows appear—sorting the data.
To sort the data rows, we include the ORDER BY clause. The ORDER BY clause includes one or
more column names that specify the sort order. If we return to one of our first
SELECT statements, we can sort its results by Class with the following statement:

SELECT student_id, FirstName, LastName, Class FROM student

ORDER BY Class

The result of the query will arrange the student in order of their class.

And the result will be:


Student_id LastName Firstname Class
1 John Hassan ss1
2 Mary Adebayo ss1
3 Agwu Ifeoluwa ss2

PRACTICE EXERCISE:
1. __________ are the primary mechanism for retrieving information from a database and
consist of questions presented to the database in a predefined format.

www.deeperlifehighschool.org …leadership with distinction


2. The SQL ________ statement is what we use to choose, or select, the data that we want
returned from the database to our application.
3. By adding a _________ clause to the SELECT statement, we add one (or more) conditions
that must be met by the selected data.
4. The ________ clause includes one or more column names that specify the sort order.
5. ___________ and ________ are the keywords for select statement among others.

TOPICAL TEST:
Objective Questions:
1. The field in a data base which uniquely identifies each record is called a A, Composite key. B.
Foreign key. C. Local key. D. Primary key [2021/22]
2. The correct order of the steps taken in creating database from database template in MS
Access 2007 is A. Click on the office button —click New__ choose a database of your choice
B. click New on the office button __choose a database your choice. C. Click on database of
your choice click new —click on office button D. Click New —choose database of your choice -
click on office button. [2021/23]
3. The function of the SQL statement SELECT Student ID, Surname, House Name FROM
Student is that it A. Retrieve the listed fields from student table B. Highlights the listed fields
from student table C. Hides the selected fields from student table D. Deletes the listed fields
from student table [2021/35]
4. Which type of key is used to establish relationships between tables in the relational model? A)
Primary key B) Foreign key C) Composite key D) Candidate key
5. Which SQL operation is used to combine rows from two or more tables based on a related
column? A) INSERT B) DELETE C) JOIN D) UPDATE
6. Which operation retrieves data from a database based on specific criteria? A) INSERT B)
UPDATE C) DELETE D) SELECT
7. Which SQL clause is used to filter rows based on a specified condition? A) GROUP BY B)
ORDER BY C) WHERE D) HAVING
8. What is the purpose of the JOIN operation in SQL? A) To create new tables B) To update
existing records C) To retrieve data from multiple related tables D) To delete rows from a table
9. Which of the following is a disadvantage of the relational model? A) Data redundancy B)
Complex data types C) Lack of data relationships D) Limited data storage
10. Which type of key is composed of multiple attributes to uniquely identify records? A)
Composite key B) Candidate key C) Primary key D) Foreign key
11. Which SQL command is used to add new rows to a table? A) ADD B) INSERT C) CREATE D)
UPDATE
12. Which SQL clause is used to group and summarize data in the result of a query? A) GROUP
BY B) ORDER BY C) HAVING D) SELECT.

Fill in the gap Questions:


1. The SQL ____________ statement is used to retrieve data from one or more tables based on
specified criteria.
2. In SQL, the ____________ keyword is used to retrieve distinct values from a column.
3. The SQL ____________ statement is used to retrieve data from one or more tables.
4. The ____________ clause is used in SQL to filter the rows returned by a query.
5. The ____________ keyword is used to retrieve distinct values from a column.

www.deeperlifehighschool.org …leadership with distinction


6. To combine rows from two or more tables based on a related column, you would use the
____________ operation.
7. The SQL ____________ statement is used to modify existing records in a table.
8. The SQL ____________ statement is used to remove records from a table.
9. The ________ clause includes one or more column names that specify the sort order.
10. ___________ and ________ are the keywords for select statement among others.

GLOSSARY OF TERMS / KEY WORDS / VOCABULARY:


1. WHERE Clause: A clause used in SELECT, UPDATE, and DELETE statements to specify
conditions for data retrieval or modification.
2. GROUP BY Clause: A clause used in conjunction with aggregate functions to group rows
based on a specific column.
3. ORDER BY Clause: A clause used to sort the result set based on specified columns.
4. Data Definition Language (DDL): A subset of SQL used to define and manage the structure of
database objects.
5. Data Manipulation Language (DML): A subset of SQL used to manipulate data within database
objects.
6. Data Control Language (DCL): A subset of SQL used to control access and permissions to
database objects.
PUZZLES / BRAIN TEASER:

INSPIRATIONAL QUOTES: “Intelligence plus character-that is the goal of true education.”


-Martin Luther King Jr.

WEEK: 9

TOPIC:PRACTICAL ON SQL

LESSON OBJECTIVES: BY THE END OF THIS LESSON STUDENTS WILL BE ABLE TO:
a)create a Table
b)insert Records into the Table
c)query the Database Table
ENTRY BEHAVIOUR: Students already know what SQL is and have gone through the
theory.

SUB-TOPIC 1:

CONTENT:Create a Table
Certainly! Let's walk through a practical example of creating a table in SQL. Suppose we want to
create a simple table to store information about books in a library. The table will have columns for
the book's ID, title, author, publication year, and ISBN (International Standard Book Number).
Here's how you could create this table using SQL:
CREATE TABLE Books (
BookID INT PRIMARY KEY,
Title VARCHAR(255) NOT NULL,
Author VARCHAR(100),

www.deeperlifehighschool.org …leadership with distinction


PublicationYear INT,
ISBN VARCHAR(13) UNIQUE );
Let's break down what's happening in this SQL statement:
1. CREATE TABLE Books: This initiates the creation of a table named "Books."
2. ( BookID INT PRIMARY KEY, ... ): Here, we're defining the columns of the table along with
their data types and constraints. The BookID column is an integer and is designated as the
primary key of the table, which ensures its uniqueness and serves as the main identifier for
each record.
3. Title VARCHAR(255) NOT NULL: The Title column is of type VARCHAR, which can store
variable-length character strings. The (255) specifies the maximum length of the string. The
NOT NULL constraint ensures that this column cannot have NULL values.
4. Author VARCHAR(100): The Author column can also hold variable-length character strings but
with a maximum length of 100 characters.
5. PublicationYear INT: The PublicationYear column is of type INT (integer), which will store the
publication year of the book.
6. ISBN VARCHAR(13) UNIQUE: The ISBN column will hold the ISBN number of the book. The
UNIQUE constraint ensures that each ISBN value is unique within the table.
This SQL statement creates the "Books" table with the specified columns and constraints. You
can execute this statement in a SQL database management tool to create the table in your
database.
Remember that the syntax and data types might vary slightly based on the specific database
system you're using (e.g., MySQL, PostgreSQL, SQL Server, etc.), but the basic structure of the
CREATE TABLE statement remains quite similar.

PRACTICE EXERCISE:
Question 1:
To create a table named "Employees" with columns for EmployeeID, FirstName, LastName, and
DepartmentID, the SQL statement would be:
CREATE TABLE Employees (
EmployeeID __________,
FirstName __________,
LastName __________,
DepartmentID __________ );

Question 2:
In SQL, the PRIMARY KEY constraint ensures __________ for the specified column(s) in a table.
Question 3:
To create a column named "Email" in a table named "Contacts" with a maximum length of 255
characters and ensuring it cannot have NULL values, you would use the data type __________
and the constraint __________.
Question 4:
The SQL CREATE TABLE statement is used to __________.
Question 5:
The UNIQUE constraint in a CREATE TABLE statement ensures that __________.

SUB-TOPIC 2:

www.deeperlifehighschool.org …leadership with distinction


CONTENT:Insert Records into the Table
Certainly! Let's walk through a practical example of inserting records into a table in SQL.
Suppose we have the "Books" table that we created earlier, and we want to insert some records
into it.
Assuming the "Books" table structure is as follows:
• BookID (INT, Primary Key)
• Title (VARCHAR)
• Author (VARCHAR)
• PublicationYear (INT)
• ISBN (VARCHAR, Unique)
Here's how you could insert a couple of records into the "Books" table using SQL:
INSERT INTO Books (BookID, Title, Author, PublicationYear, ISBN)
VALUES
(1, 'The Great Gatsby', 'F. Scott Fitzgerald', 1925, '978-3-16-148410-0'), (2, 'To Kill a
Mockingbird', 'Harper Lee', 1960, '978-0-06-112008-4');
Let's break down what's happening in this SQL statement:
1. INSERT INTO Books: This indicates that we're inserting data into the "Books" table.
2. (BookID, Title, Author, PublicationYear, ISBN): This specifies the columns that we're providing
values for in the VALUES clause.
3. VALUES: This keyword indicates that we're providing the actual values that need to be
inserted.
4. (1, 'The Great Gatsby', 'F. Scott Fitzgerald', 1925, '978-3-16-148410-0'): This is the set of
values for the first record we're inserting.
5. (2, 'To Kill a Mockingbird', 'Harper Lee', 1960, '978-0-06-112008-4'): This is the set of values for
the second record.
You can execute this SQL statement in your database management tool to insert these records
into the "Books" table.
Remember to adjust the values and column order based on your specific table structure and data.
Also, always ensure that the data you're inserting adheres to any constraints defined on the table,
such as unique or not-null constraints.

PRACTICE EXERCISE:
1. To insert a new customer with CustomerID 101, FirstName "John," LastName "Doe," and
Email "[email protected]" into a table named "Customers," the SQL statement would be:
INSERT INTO Customers (
CustomerID,
FirstName,
LastName,
Email)
VALUES (
__________,
__________,
__________,
__________
);
2. In the SQL INSERT INTO statement, the VALUES keyword is followed by __________, which
represent the actual values to be inserted into the table.

www.deeperlifehighschool.org …leadership with distinction


3. If you want to insert multiple records into a table using a single INSERT INTO statement, you
can separate each set of values using __________.
4. When inserting records into a table with an auto-incrementing primary key, you typically omit
the __________ column in the INSERT INTO statement.
5. If a column is defined as NOT NULL in the table, you must provide a value for that column
while __________ records.
SUB-TOPIC 3:

CONTENT:Query the Database Table


Absolutely! Let's walk through a practical example of querying a database table using SQL.
Suppose we have the "Books" table from before, and we want to retrieve information about books
published after the year 2000.
Assuming the "Books" table structure is as follows:
• BookID (INT, Primary Key)
• Title (VARCHAR)
• Author (VARCHAR)
• PublicationYear (INT)
• ISBN (VARCHAR, Unique)
Here's how you could query the "Books" table to retrieve books published after the year 2000:

SELECT Title, Author, PublicationYear, ISBN FROM Books WHERE


PublicationYear> 2000;
Let's break down what's happening in this SQL statement:
1. SELECT Title, Author, PublicationYear, ISBN: This part specifies which columns you want to
retrieve in the query result.
2. FROM Books: This indicates the table you're querying from, which is the "Books" table in this
case.
3. WHERE PublicationYear> 2000: This part filters the results based on a condition. In this case,
it retrieves only the rows where the "PublicationYear" is greater than 2000.
This SQL query will retrieve the titles, authors, publication years, and ISBNs of books that were
published after the year 2000 from the "Books" table.
Feel free to modify the query to suit your specific needs or experiment with other filtering
conditions.
Remember that SQL queries can vary slightly depending on the database system you're using
(e.g., MySQL, PostgreSQL, SQL Server), but the basic syntax for SELECTing and filtering data
remains consistent

PRACTICE EXERCISE:
1. To retrieve all columns of the "Customers" table for customers who have a "Premium"
membership, the SQL query would be:
SELECT __________ FROM Customers WHERE MembershipType = 'Premium';
2. To retrieve the "ProductName" and "UnitPrice" columns of the "Products" table for products
with a unit price less than $50, the SQL query would be:
SELECT __________, __________ FROM Products WHERE UnitPrice< 50;
3. In the SQL query SELECT FirstName, LastName FROM Employees WHERE DepartmentID
= 3;, the SELECT clause specifies the __________ you want to retrieve.
4. The WHERE clause in an SQL query is used to __________.

www.deeperlifehighschool.org …leadership with distinction


5. To retrieve the highest "Score" from the "ExamResults" table, the SQL query would be:
SELECT __________(Score) FROM ExamResults;

TOPICAL TEST:
Multiple Choice Questions:
1. What is the purpose of the PRIMARY KEY constraint in a CREATE TABLE statement? a)
Ensures the uniqueness of values in the specified column(s) b) Sets the default value for a
column c) Specifies the column order in the table d) Provides a hint for optimizing query
performance
2. Which SQL data type is typically used for storing large amounts of text data, such as a
paragraph or a description? a) INT b) VARCHAR c) TEXT d) FLOAT
3. What does the NOT NULL constraint indicate in a column definition? a) The column can have
NULL values b) The column must have unique values c) The column cannot have NULL
values d) The column can have multiple values
4. Which of the following is used to specify a unique identifier for each row in a table? a) INDEX
b) FOREIGN KEY c) PRIMARY KEY d) UNIQUE
5. The AUTO_INCREMENT attribute in MySQL is used to: a) Automatically update values in a
column b) Increment the column value by a fixed amount c) Automatically generate unique
values for a column d) Automatically sort the table based on the column
6. Question 1: In SQL, the INSERT INTO statement is used to: a) Create a new table b) Delete
records from a table c) Insert records into a table d) Update records in a table
7. Question 2: What is the purpose of the VALUES keyword in the INSERT INTO statement? a)
It specifies the columns to be inserted into b) It indicates the data type of the inserted values
c) It defines constraints for the inserted values d) It provides the actual values to be inserted
8. Question 3: When inserting records into a table, the order of the values in the VALUES clause
must match the: a) Order of columns in the table b) Order of indexes in the table c) Order of
constraints in the table d) Order of triggers in the table
9. Question 4: If a column is not specified in the INSERT INTO statement and it's defined with an
auto-incrementing primary key, what happens? a) The table won't allow insertions b) An error
occurs, and the insertion fails c) The column's value will be automatically generated d) The
column's value defaults to NULL
10. Question 5: When inserting multiple records using a single INSERT INTO statement, the
values for each record are separated by: a) Commas (,) b) Semicolons (;) c) Vertical bars (|)
d) Colons (:)

Fill in the gap Question


1. To retrieve all columns of the "Orders" table, the SQL query would be:
SELECT __________ FROM Orders;
2. To retrieve the "ProductName" and "Quantity" columns of the "OrderDetails" table for orders
with OrderID 1001, the SQL query would be:
SELECT __________, __________ FROM OrderDetails WHERE OrderID = 1001;
3. In the SQL query SELECT FirstName, LastName FROM Employees WHERE DepartmentID =
2;, the SELECT clause specifies the __________ you want to retriev
4. To retrieve distinct values from the "City" column of the "Customers" table, the SQL query
would be:

www.deeperlifehighschool.org …leadership with distinction


SELECT DISTINCT __________ FROM Customers;
5. The WHERE clause in an SQL query is used to __________.
6. To retrieve the total sum of the "Price" column in the "Products" table, the SQL query would
be:
SELECT SUM(__________) FROM Products;
7. To retrieve the top 5 highest scores from the "ExamResults" table, the SQL query would be:
SELECT TOP 5 __________ FROM ExamResults ORDER BY Score DESC;
8. To retrieve the count of distinct "Category" values in the "Products" table, the SQL query
would be:
SELECT COUNT(DISTINCT __________) FROM Products;
9. To retrieve records from the "Students" table where the "Age" is between 18 and 25, the SQL
query would be:
SELECT __________ FROM Students WHERE Age BETWEEN 18 AND 25;
10. To retrieve the average "Salary" of employees in the "Employees" table, the SQL query would
be:
SELECT AVG(__________) FROM Employees;

GLOSSARY OF TERMS / KEY WORDS / VOCABULARY:


1. SQL (Structured Query Language): A domain-specific language used for managing and
manipulating relational databases. SQL allows you to define, manipulate, query, and control
data within a relational database management system (RDBMS).
2. Database: A structured collection of data organized in tables with related information.
3. Table: A database object that stores data in rows (records) and columns (fields).
4. Column: A single attribute or data field within a table that holds specific types of data.
5. Row (Record): A single set of data within a table, representing a unique entity or item.
6. SELECT: An SQL statement used to retrieve data from one or more tables. It forms the basis
of queries.
7. FROM: A clause in the SQL SELECT statement specifying the table(s) from which data is
being retrieved.
8. WHERE: A clause in the SQL SELECT statement used to filter rows based on specific
conditions.
9. ORDER BY: A clause used to sort the result set of a query in ascending or descending order
based on specified columns.
10. LIMIT (or TOP): A clause used to restrict the number of rows returned by a query, useful for
displaying a subset of results.
11. DISTINCT: A keyword used to eliminate duplicate values from the result set.
12. UPDATE: An SQL statement used to modify existing records in a table based on specified
conditions.
13. SET: A clause used in the UPDATE statement to define the new values for the columns being
modified.
14. INSERT INTO: An SQL statement used to add new records into a table.
15. VALUES: A clause used with the INSERT INTO statement to specify the actual data values to
be inserted.
16. DELETE: An SQL statement used to remove rows from a table based on specified conditions.
17. JOIN: A SQL operation that combines rows from two or more tables based on a related column
between them.

www.deeperlifehighschool.org …leadership with distinction


18. PRIMARY KEY: A column or set of columns in a table that uniquely identifies each row,
enforcing data integrity.
19. FOREIGN KEY: A column in one table that is linked to the primary key of another table,
creating a relationship between the two tables.
20. INDEX: A database structure that improves the speed of data retrieval operations on a table.

PUZZLES / BRAIN TEASER:


Puzzle 1: Query Challenge - Ordering and Limiting Results
Consider a table named "Movies" with columns "Title," "ReleaseYear," and "Rating." Write an SQL
query to retrieve the top 5 highest-rated movies released after the year 2000, ordered by their
ratings in descending order.
Puzzle 2: Update Challenge - Modifying Records
You have a table named "Products" with columns "ProductID," "ProductName," and "UnitPrice."
Some of the products have incorrect prices due to a data entry error. Write an SQL query to
update the unit price of all products with a price greater than $100 to reduce their price by 10%.

INSPIRATIONAL QUOTES: “Education is the most powerful weapon which you can use to change the
world.”
-Nelson Mandela

www.deeperlifehighschool.org …leadership with distinction

You might also like