Ss 2 Data Processing First Term E-Note
Ss 2 Data Processing First Term E-Note
DATA PROCESSING
CLASS:
S.S. 2
TERM: FIRST
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:
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)
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 _______________________
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
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.
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.
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
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 ________________
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
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.
WEEK: 2
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.
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
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:
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 ________
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
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?
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.
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:
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.
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)
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.
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.
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.
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:
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
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
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.
INSPIRATIONAL QUOTES: “A teacher affects eternity; he can never tell where his influence stops.”
-Henry B. Adams
WEEK: 5
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:
Unit price
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.
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:
Date Activity
Code Route
No
01/12/01 24 1-95
01/15/01 23 1-495
02/08/01 24 1-66
The purpose of the relational model is to provide a declarative method for specifying data and
queries.
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
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[, ...]]) |
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
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]
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:
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.
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:
We can continue with our previous query, and limit it to only those students in 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.
ORDER BY Class
The result of the query will arrange the student in order of their class.
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.
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.
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),
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:
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.
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 __________.
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 (:)
INSPIRATIONAL QUOTES: “Education is the most powerful weapon which you can use to change the
world.”
-Nelson Mandela