ITDSA2-12 Week 2 2
ITDSA2-12 Week 2 2
Disclaimer
Eduvos and the Flipped Classroom
1 2 3
Pre-Session Assessment
What will be covered in this week’s sessions?
•
•
•
•
•
•
•
Data Modelling
Data modeling is the first step in the database design journey, serving as a
bridge between real-world objects and the computer database.
Data modeling, the first step in designing a database, refers to the process of
creating a specific data model for a determined problem domain.
1.Entity - A person, place, thing, concept, or event for which data can be stored.
An entity represents a particular type of object in the real world, which means an
entity is “distinguishable” with each entity occurrence being unique and
distinct.
For example, a CUSTOMER entity would have many distinguishable customer
occurrences, such as Kusakana Mashilo or Ngobeni Tshabalala
Data Model Basic Building Blocks
2. Attribute - A characteristic of an entity or object. An attribute has a name and a data
type.
For example, a CUSTOMER entity would be described by attributes such as customer last name,
customer first name, customer phone number, customer address, and customer credit limit.
Associations among two or more entities that are used by data models. In a 1:M relationship,
one entity instance is associated with many instances of the related entity.
Example: A painter creates many different paintings, but each is painted by only one painter.
Thus, the painter (the “one”) is related to the paintings (the “many”).
Data Model Basic Building Blocks
• one-to-many (1:M or 1..*) relationship
Associations among two or more entities that are used by data models. In a 1:M relationship, one
entity instance is associated with many instances of the related entity.
Example: A painter creates many different paintings, but each is painted by only one painter. Thus, the
painter (the “one”) is related to the paintings (the “many”).
Associations among two or more entities that are used by data models. In a 1:1 relationship, one
entity instance is associated with only one instance of the related entity.
Example: A retail company’s management structure may require that each of its stores be managed by
a single employee. In turn, each store manager, who is an employee, manages only a single store.
Data Model Basic Building Blocks
4. Constraint is a restriction placed on the data. Constraints are
important because they help to ensure data integrity. Constraints are
normally expressed in the form of rules:
For example, “A student’s GPA must be between 0.00 and 4.00.”
Data Model Techniques
Evolution of Data Models
Importance of Data Models
The primary goal of using data model are:
•Ensures that all data objects required by the database are accurately represented. Omission of data will lead
to creation of faulty reports and produce incorrect results.
•A data model helps design the database at the conceptual, physical and logical levels.
•Data Model structure helps to define the relational tables, primary and foreign keys and stored procedures.
•It provides a clear picture of the base data and can be used by database developers to create a physical
database.
There are mainly three different types of data models: conceptual data models,
logical data models, and physical data models, and each one has a specific
purpose. The data models are used to represent the data and how it is stored in the
database and to set the relationship between data items.
Types of Data Models in DBMS
There are mainly three different types of
data models: conceptual data models,
logical data models, and physical data
models, and each one has a specific
purpose. The data models are used to
represent the data and how it is stored in
the database and to set the relationship
between data items.
Types of Data Models in DBMS
1. Conceptual data model
Business rule
A description of a policy, procedure, or principle within an organization. For
example, a pilot cannot be on duty for more than 10 hours during a 24-hour period,
or a professor may teach up to four classes during a semester.
Business Rules In Data Modelling
Translating Business Rules into Data Model Components
As a general rule, a noun in a business rule will translate into an entity in the model, and a
verb (active or passive) that associates the nouns will translate into a relationship among
the entities.
For example, the business rule “a customer may generate many invoices” contains
two nouns (customer and invoices) and a verb (generate) that associates the nouns.
From this business rule, you could deduce the following:
• Customer and invoice are objects of interest for the environment and should be
represented by their respective entities.
• There is a generate relationship between customer and invoice.
Business Rules In Data Modelling
To properly identify the relationship type, you should generally ask two questions:
For example, you can assess the relationship between student and class by asking two
questions:
• In how many classes can one student enroll? Answer: many classes.
• How many students can enroll in one class? Answer: many students.
• An attribute name should also be descriptive of the data represented by that attribute.
It is also a good practice to prefix the name of an attribute with the name or
abbreviation of the entity in which it occurs. For example, in the CUSTOMER entity, the
customer’s credit limit may be called CUS_CREDIT_LIMIT. The CUS indicates that the
attribute is descriptive of the CUSTOMER entity, while CREDIT_LIMIT makes it easy to
recognize the data that will be contained in the attribute.
Graph Data Modelling
Data modeling with graphs is a technique
that represents and organizes data using a
graph structure, which consists of nodes,
edges, and properties.
• The logical view of the relational database is facilitated by the creation of data relationships
end users find it much easier to think of a relation as a table. A table is perceived as a two-
dimensional structure composed of rows and columns. A table is also called a relation because
the relational model’s creator, E. F. Codd, used the two terms as synonyms.
Characteristics of a Relational Table
Note
Technically, a null in a database is not a value and it is not an entry—it is the absence
of a value and the absence of an entry. However, for conversational convenience, even
database professionals and database vendors will often refer to a null in the database as
a“null value”or a“null entry.”
Integrity Rules
An Illustration of Integrity Rules
Entity integrity. The CUSTOMER table’s primary key
is CUS_CODE. The CUSTOMER primary key column
has no null entries, and all entries are unique.
Similarly, the AGENT table’s primary key is
AGENT_CODE, and this primary key column is also
free of null entries.
1. Insert
2. Update
3. Delete
4. Select.
Whenever one of these operations are applied, integrity constraints specified on the
relational database schema must never be violated.
Operations in Relational Model
1. Insert Operation
The insert operation gives values of the attribute for a new tuple which should be inserted into
a relation.
Operations in Relational Model
2. Update Operation
You can see that in the below-given relation table CustomerName= ‘Thapelo’ is
updated from Inactive to Active.
Operations in Relational Model
3. Delete Operation
To specify deletion, a condition on the attributes of the relation selects the tuple to be
deleted.
Operations in Relational Model
4. Select Operation
1. Structured Data Representation: Both relational and graph data models provide structured
representations for data. In relational databases, data is organized into tables with rows and columns,
while in graph databases, data is structured as nodes and edges.
Similarities Between Relational
and Graph Data Models
2. Use of Relationships: Both models incorporate the concept of relationships between data
elements. In relational databases, relationships are established through foreign key constraints,
linking records in different tables. In graph databases, relationships are explicitly represented as edges
connecting nodes.
3. Query Language: SQL (Structured Query Language) is commonly used to query relational
databases, enabling users to retrieve, manipulate, and analyze data. Similarly, graph databases often
use query languages tailored to traverse and query graph structures, such as Cypher (used in Neo4j).
4. ACID Properties (Atomicity, Consistency, Isolation, Durability): Relational and graph databases
both adhere to the ACID properties, ensuring data consistency and integrity. Transactions in both
models are designed to be atomic, consistent, isolated, and durable.
Similarities Between Relational
and Graph Data Models
2. Use of Relationships: Both models incorporate the concept of relationships between data
elements. In relational databases, relationships are established through foreign key constraints,
linking records in different tables. In graph databases, relationships are explicitly represented as edges
connecting nodes.
3. Query Language: SQL (Structured Query Language) is commonly used to query relational
databases, enabling users to retrieve, manipulate, and analyze data. Similarly, graph databases often
use query languages tailored to traverse and query graph structures, such as Cypher (used in Neo4j).
4. ACID Properties (Atomicity, Consistency, Isolation, Durability): Relational and graph databases
both adhere to the ACID properties, ensuring data consistency and integrity. Transactions in both
models are designed to be atomic, consistent, isolated, and durable.
Similarities Between Relational
and Graph Data Models
5. Data Integrity and Constraints: Both models support the enforcement of data integrity through
constraints. In relational databases, constraints include primary keys, foreign keys, and unique
constraints. In graph databases, constraints may involve specifying the types of relationships between
nodes or defining unique identifiers for nodes.
6. Indexes for Performance Optimization: Relational and graph databases both utilize indexes to
optimize query performance. Indexing is used to accelerate data retrieval operations by providing a
fast lookup mechanism. In relational databases, indexes are applied to columns, while in graph
databases, indexes may be used on node or relationship properties.
Comparison Between Relational
and Graph Data Models
Case Study