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

0% found this document useful (0 votes)
4 views11 pages

Ss2 First Term Note

Uploaded by

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

Ss2 First Term Note

Uploaded by

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

Subject: Computer Science

Class: Ss2
Term: First Term
Duration: 40 minutes
TOPICS:
1. Types of data models
2. Data modelling
3. Normal forms
4. Entity relationship model
5. Relational modelling

TOPIC 1: Definition of a Data Model

A data model is a way of organizing and representing data in a database. It describes how
data is connected, stored, and processed.

Types of Data Models

1. Hierarchical Data Model

In a hierarchical database, data is organized into an upside-down tree-like structure,


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

 Organizes data in a tree-like structure.


 Data is stored in parent-child relationships.
 One parent can have many children, but a child has only one parent.
 Example: An organization where a manager supervises multiple employees.

2. Network Data Model

This model organizes data using two fundamental construct, called records and sets.
Records contain fields, and sets define one-to-many relationships between records: one
owner, many members

 Similar to the hierarchical model but allows many-to-many relationships.


 A child can have multiple parents.
 Example: A student enrolled in multiple courses, and each course has many students.
3. Relational Data Model

The relational model or relational data base model is based on first-order predicate
logic. Its core idea is to describe a database as a collection of predicates over a finite
set of predicate variables, describing constraints on the possible values and
combinations of values.

 Stores data in tables (also called relations).


 Each table has rows and columns.
 It is the most commonly used model in modern databases.
 Example: A table of students with columns for name, age, and ID.

4. Object-Oriented Data Model

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

o Combines database and object-oriented programming concepts.


o Stores data as objects (like in programming).
o Useful for complex data like multimedia and engineering data.

TOPIC 2: DATA MODELLING

Introduction to Data Modelling


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

Definition of Data Modelling

Data modelling is the process of creating a structure for how data will be stored, organized,
and accessed in a database.

Data Modelling is the process of structuring and organizing data. The data structures are then
typically implemented in a database management system. In addition to defining and
organizing the data, data modelling may also impose constraints or limitations on data placed
within the structure.
Managing large quantities of structure and unstructured data is a primary function of
information systems. Data Models describe structured data for storage in data management
system such as relational databases. They do not describe unstructured data such as word
processing documents, email messages, pictures, digital audio and video

Concept of Data Modelling


 Data modelling techniques and tools help to capture and translate complex system designs
into easily understood representation of data flows and processes, creating a blueprint for
construction and re-engineering.
 Data Models provide a structure for data used within information system by providing
specific definition and format.
 Data Model shows the dataflow and logical interrelationship among different data elements.
 Compatibility of data can be achieved, if a data model is consistently used across the
systems.

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

Data Structure: A data model describes the structure of the data within a given domain and,
by implication, the underlying structure of that domain itself.
Data Organization: A data Model also describes how to organized data using a database
management system.

Approach in Data Modelling


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

Purpose of Data Modelling

 To ensure data is organized properly.


 To reduce redundancy (repetition).
 To improve data consistency and accuracy.
 To help in designing a database before it’s built.

Steps in Data Modelling

1. Identify Entities: Things we want to store data about (e.g., Student, Teacher).
2. Identify Attributes: Properties of the entities (e.g., Student Name, Age).
3. Identify Relationships: How entities are connected (e.g., A student enrolls in
courses).
4. Draw ER Diagram: Visual representation of entities and their relationships.

TOPIC 3: NORMAL FORMS

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


define, create and maintain a database. Defining a database involves specifying constraints
for the data stored in the database, and normalization is a logical design method which
minimizes duplicate, or redundant, data and design flaws. Normalization is the process of
effectively organizing data in a database. The primary purpose of normalization is to allow
update, insert and delete operations to be performed on a single database table and
propagated throughout the database by means of the defined relationship.
There are two goals of the normalization process:
 Eliminating redundant data (for example storing the same data in more than one table)
 Ensuring data dependencies make sense (only storing related data in a table)

Definition Normal Form

Normal forms are rules used to organize database tables to reduce redundancy and improve
data integrity.

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

Types of Normal Forms

1. First Normal Form (1NF)


o Data is in tabular form.
o Each column contains atomic (indivisible) values.
o No repeating groups.
o Example: A table should not have multiple phone numbers in one column.
2. Second Normal Form (2NF)
o Must first satisfy 1NF.
o All non-key attributes must depend on the whole primary key (not part of it).
o Removes partial dependencies.
3. Third Normal Form (3NF)
o Must first satisfy 2NF.
o No transitive dependency (non-key attributes depending on other non-key
attributes).
o Improves data structure and avoids duplication.

The Fourth Normal Form (4NF) and Fifth Normal Form (5NF) are beyond the scope of this
syllabus

TOPIC 4: ENTITY RELATIONSHIP MODEL (ER MODEL)

Definition

An ER model is a diagram that shows entities, their attributes, and how they relate to each
other in a database.

Components of ER Model

1. Entity – A real-world object or concept (e.g., Student, Book).


2. Attribute – A property or detail about an entity (e.g., Student Name, Book Title).
3. Relationship – Connection between entities (e.g., A student borrows a book).

ER Diagram Symbols

 Rectangle: Entity
 Oval: Attribute
 Diamond: Relationship
 Lines: Connect entities to attributes and relationships

Example

Imagine a school database:

 Entities: Student, Course


 Attributes: Student (ID, Name), Course (Code, Title)
 Relationship: Student “enrolls in” Course
 CONTENT

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


other. Entity relationship diagrams (ERDs) illustrate the logical structure of database.
Diagrams created to design these entities and relationships are called entity-relationship
diagrams or ER diagram.
Entity: An entity is an object that exists and which is distinguishable from other objects. An
entity can be a person, a place, an object, an event, or a concept which an organization wishes
to maintain data. The following are some examples of entities:
 Person: STUDENT, EMPLOYEE, CLIENT
 Object: COUCH, AIRPLANE, MACHINE
 Place: CITY, ROOM, WAREHOUSE
 Concept: PROJECT, ACCOUNT, COURSE

An entity type defines a collection of entities that have same attributes. An entity instance is a
single item in this collection. An entity set is a set of entity instances. For example,
STUDENT is an entity type; a student with ID number ISI070 is an entity instance; and a
collection of all students is an entity set.

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


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

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

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

Degree Of A Relationship
The number of entity sets that participate in a relationship is called the degree of relationship.
The 3 most common degrees of relationship are unary (degree 1), binary (degree 2) and
ternary (degree 3).
1. Unary relationship: A unary relationship exists when there is an association between two
instances of the same entity type. For example, in an organization, an employee will manage
one or more employee.
2. Binary relationship: A binary relationship exists when there is an association between
two instances of two different entity types. For example, in a secondary school, a binary
relationship exists between a Subject (SUBJECT entity) and a Teacher (TEACHER entity); a
teacher teaches (a) subject.
3. Ternary Relationship: A ternary relationship exists when there is an association between
three instances of three different entity types. For example, consider a student using certain
equipment for a project. In this case, the STUDENT, PROJECT, and EQUIPMENT entity
types relate to each other with ternary relationships: a student checks out equipment for a
project.

Cardinality Of A Relationship
The cardinality is the number of occurrences in one entity which are associated (or linked) to
the number of occurrences in another entity. For example, if the entity types A and B are
connected by a relationship, then the maximum cardinality represents the maximum number
of instances of entity B that can be associated with any instance of entity A. There are three

Types Of Relationship

1. One-to-One Relationship: In a one-to-one relationship, at most one instance of entity B


can be associated with a given instance of entity A and vice versa. For example an employee
is assigned a parking space or an employee manages the department.
2. One-to-Many (or many-to-one) Relationship: In a one-to-many relationship, many
instances of entity B can be associated with a given instance of entity A. However, only one
instance of entity A can be associated with a given instance of entity B. For example, many
employee works in a department or a school has many employees.
3. Many-to-Many Relationship: In a many-to-many relationship, many instances of entity A
can be associated with a given instance of entity B, and, likewise, many instances of entity B
can be associated with a given instance of entity A. For example, many employees work on
many projects.

Uses of Entity Relationship Diagram


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

Definition

Relational modelling is the process of designing a database using the relational data model
(tables).

Key Terms

 Table (Relation) – Set of rows and columns.


 Row (Tuple) – A record (e.g., one student’s data).
 Column (Attribute) – A field (e.g., Name, Age).
 Primary Key – A unique identifier for each record (e.g., Student ID).
 Foreign Key – A field in one table that links to the primary key in another.

Advantages of Relational Modelling

 Easy to understand and use


 Supports data integrity
 Allows complex queries
 Reduces data duplication

Example of Tables

Student Table

StudentID Name Age


001 Musa 16
002 Amina 17

Course Table

CourseID Title
C01 Mathematics
C02 English

Enrollment Table

StudentID CourseID
001 C01
001 C02

Summary
Concept Meaning
Data Model A way to organize and represent data
Data Modelling Designing the structure of a database
Normal Forms Rules to organize tables and reduce duplication
ER Model Diagram showing entities and relationships
Relational Modelling Creating tables with primary and foreign keys

Relational Models

A relational model gives a simple way of representing data in form of a two-dimensional


table called relation. Relational model was invented by Edger Codd. The columns or fields in
the table identify the attribute such as surname, last name, age, gender, Admission number
etc. A tuple or row contains all the data of a single instance of the table such as a person
named James Bond. In the relational model, every tuple must have a unique identification or
key based on the data. In the table below, the Admission number is the key that uniquely
identifies each tuple in the relation. Keys are often used to join data from two or more
relations based on matching identification. Another concept used in a relational model is the
foreign keys, which are primary keys in one relation that are kept in another relation to allow
for the joining of data

Definition Of Terms
1. Field: is a named column in the relation (table). There are five fields in the student relation
above – Admission number, Surname, Last name, Age, Gender.
2.Tuple: is a record (i.e. a row of data in a relation). All tuples in a relation must be distinct.
3. Domain: is defined as the set of all unique values permitted for an attribute. For example,
the domain of the field Gender as seen in the table above is M and F. Also the domain of the
attribute Surname consist the combination of all possible letters in the alphabet. A domain is
referred to in a relation schema by the domain name and has a set of values.
4. The Degree (also called arity) of a relation is the number of fields in it. The relation above
is of degree 5.
5. The cardinality of a relation is the number of tuples in it. For example, the relation above
contains 6 tuples and hence the cardinality is 6.
6. A relational database is a collection of relations with distinct names that can be linked
together.
7. Relation schema describes the column heads of the table. The schema specifies the
relation’s name, the name of the field (or attribute or column) and the domain of each field.

SUMMARY

1. Types of Data Models:

Conceptual Data Model:

Represents the overall structure of a database, focusing on the entities and relationships
between them without considering specific implementation details. It's like a high-level
overview of the data.
Logical Data Model:

Translates the conceptual model into a structure that can be implemented using a database
management system (DBMS). This model defines tables, columns, and their relationships,
but doesn't specify the physical storage.

Physical Data Model:

Defines how the data is actually stored in the database, considering physical storage details
like indexes, file organization, and access methods.

2. Data Modeling:

Data modeling is the process of designing and structuring a database to efficiently store and
retrieve information. It involves identifying entities, attributes, and relationships between
them to create a logical representation of the data.

Key steps in data modeling:

Identify entities:

Entities are the things or concepts about which you want to store data (e.g., students, courses,
and teachers).

Define attributes:

Attributes are the characteristics or properties of each entity (e.g., student name, course code,
and grade).

Establish relationships:

Relationships define how entities are related to each other (e.g., a student can enroll in many
courses).

3. Normal Forms:

Normal forms are a set of rules used to design databases to minimize redundancy and ensure
data consistency. They help to avoid anomalies like update, insertion, and deletion anomalies.

First Normal Form (1NF):

Each attribute in a table should depend only on the primary key of that table.

Second Normal Form (2NF):

A table is in 2NF if it is in 1NF and every non-key attribute depends entirely on the primary
key, not on any part of the primary key.

Third Normal Form (3NF):


A table is in 3NF if it is in 2NF and every non-key attribute depends only on the primary key,
not on any other non-key attribute.

4. Entity Relationship Model (ER Model):

The ER model is a graphical representation of entities, attributes, and relationships between


them. It is a common tool used in data modeling to visually depict how data is structured and
related.

Key components of an ER model:

Entities: Represented by rectangles.

Attributes: Attributes are the properties of entities, represented by oval shapes connected to
the entities.

Relationships: Relationships between entities are represented by lines connecting the


rectangles. Cardinality specifies the number of instances of one entity that can be related to
another entity (e.g., one student can enroll in many courses).

5. Relational Modeling:

The relational model is a database model that organizes data into tables (relations) where
each table consists of rows (tuples) and columns (attributes). Tables are related to each other
through shared attributes, allowing for efficient querying and data retrieval.

Key features of the relational model:

Tables: Tables store data in a structured format.

Keys: Primary keys uniquely identify each row in a table, while foreign keys reference other
tables to establish relationships.

SQL: Structured Query Language (SQL) is used to manipulate and query data in relational
databases.

You might also like