1 of 35

DATA MODELS

  • GULLAGONG

Associate Prof.

P.G. Deptt. Of Comp. sc. & IT

2 of 35

What are the Data Models in DBMS?

  • The Data Model gives us an idea of how the final system would look after it has been fully implemented. It specifies the data items as well as the relationships between them. In a database management system, data models are often used to show how data is connected, stored, accessed, and changed. We portray the information using a set of symbols and language so that members of an organisation may understand and comprehend it and then communicate.

3 of 35

Types of Data Models in DBMS

  • Though there are other data models in use today, the Relational model is the most used. Aside from the relational model, there are a variety of different data models that we shall discuss in-depth in this article. Data Models in DBMS include the following:
  • Hierarchical Model
  • This concept uses a hierarchical tree structure to organise the data. The hierarchy begins at the root, which contains root data, and then grows into a tree as child nodes are added to the parent node.
  • Network Model
  • The main difference between this model and the hierarchical model is that any record can have several parents in the network model. It uses a graph instead of a hierarchical tree.

4 of 35

  • Entity-Relationship Model
  • The real-world problem is depicted in visual form in this model to make it easier for stakeholders to comprehend. The ER diagram also makes it very simple for developers to comprehend the system. Relational Model
  • The data in this model is kept in the form of a table that is two-dimensional. All of the data is kept in the form of rows and columns. Tables are the foundation of a relational paradigm.
  • Object-Oriented Data Model
  • Both the data and the relationship are contained in a single structure that is known as an object in this model. We can now store audio, video, pictures, and other types of data in databases, which was previously impossible with the relational approach (Although you can store video and audio in relational DB, it is advised not to store them in the relational database).

5 of 35

What is the Hierarchical Model in DBMS?

  • The Hierarchical Model was the first database management system model. This concept uses a hierarchical tree structure to organise the data. The hierarchy begins at the root, which contains root data, and then grows into a tree as child nodes are added to the parent node. This model accurately depicts several real-world relationships such as food recipes, website sitemaps, and so on.�Example�The following diagram depicts the relationship between the shoes available on a shopping website:�

6 of 35

7 of 35

  • Features of a Hierarchical Model
  • 1. Parent-Child Relationship
  • A parent node exists for each child node. However, a parent node might have several child nodes. It is not permitted to have more than one parent.
  • 2. One-to-many Relationship
  • The data is organised in a tree-like form, with the datatypes having a one-to-many relationship. There can only be one path from any node to its parent. For example, in the preceding example, there is only one way to get to the node ‘sneakers’, which is through the ‘men’s shoes’ node.
  • 3. Deletion Problem
  • When a parent node is removed, the child node is removed as well.
  • 4. Pointers
  • Pointers are used to connect the parent and child nodes and to traverse and navigate between the stored data. The ‘shoes’ node in the above example points to the two additional nodes, ‘women’s shoes’ and ‘men’s shoes.’

8 of 35

  • Pros of Hierarchical Model
  • A tree-like structure is incredibly straightforward and quick to navigate.
  • Any modification to the parent node is reflected automatically in the child node, ensuring data integrity.
  • Cons of Hierarchical Model
  • Relationships that are complex are not supported.
  • Because it only supports one parent per child node, if we have a complex relationship in which a child node needs to have two parents, we won’t be able to describe it using this model.
  • When a parent node is removed, the child node is removed as well.

9 of 35

What is the Network Model in DBMS?

  • The hierarchical model is extended in the network model. Prior to the relational model, it was the most popular model. To increase database performance and standards, the network model was devised to express complicated data relationships more effectively than hierarchical models. It has entities that are grouped in a graphical format, and some of the entities can be reached by many paths.�Example�We can observe that the node student has two parents, CSE Department and Library, in the example below. In the hierarchical model, this was previously impossible.

10 of 35

11 of 35

  • Features of a Network Model
  • 1. Multiple Paths
  • There may be several paths to the same record due to the increased number of relationships. It allows for quick and easy data access.
  • 2. The Ability to Merge More Relationships
  • Data is more connected in this model since there are more relationships. This paradigm can handle many-to-many as well as one-to-one relationships.
  • 3. Circular Linked List
  • The circular linked list is used to perform operations on the network model. The present position is kept up to date with the help of a software, and it navigates through the records based on the relationship.

12 of 35

  • Pros of Network Model
  • In comparison to the hierarchical model, data can be retrieved faster. This is because the data in the network model is more related, and there may be more than one path to a given node. As a result, the data can be accessed in a variety of ways.
  • Data integrity is present since there is a parent-child relationship. Any changes to the parent record are mirrored in the child record.
  • Cons of Network Model
  • As the number of relationships to be managed grows, the system may get increasingly complicated. To operate with the model, a user must have a thorough understanding of it.
  • Any alteration, such as an update, deletion, or insertion, is extremely difficult.

13 of 35

What is a Relational Model in DBMS?

  • The relational model represents DB in the form of a collection of various relations. This relation refers to a table of various values. And every row present in the table happens to denote some real-world entities or relationships. The names of tables and columns help us interpret the meaning of the values present in every row of the table. This data gets represented in the form of a set of various relations. Thus, in the relational model, basically, this data is stored in the form of tables. However, this data’s physical storage is independent of its logical organisation.�Popular Relational Database Management Systems:�IBM – DB2 and Informix Dynamic Server�Oracle – Oracle and RDB�Microsoft – SQL Server and Access

14 of 35

  • Properties of a Relational Model
  • The relational databases consist of the following properties:
  • Every row is unique
  • All of the values present in a column hold the same data type
  • Values are atomic
  • The columns sequence is not significant
  • The rows sequence is not significant
  • The name of every column is unique

15 of 35

  • Illustration of the Relational Model
  • A relational model represents how we can store data in Relational Databases. Here, a relational database stores information in the form of relations or tables.
  • Now, let us consider a relation EMPLOYEE with attributes ID_NO, NAME, ADDRESS, ROLL_NO, and AGE shown in this table:

ID_NO

NAME

ADDRESS

ROLL_NO

AGE

C1

RIYA

DELHI

15

20

C2

SUNITA

GURGAON

16

22

C3

ASHWANI

ROHTAK

12

18

C4

PREETI

DELHI

25

EMPLOYEE

16 of 35

  • Important Terminologies
  • Here are some Relational Model concepts in DBMS:
  • Attribute: It refers to every column present in a table. The attributes refer to the properties that help us define a relation. E.g., Employee_ID, Student_Rollno, SECTION, NAME, etc.
  • Tuple – It is a single row of a table that consists of a single record. The relation above consists of four tuples, one of which is like:

  • Tables – In the case of the relational model, all relations are saved in the table format, and it is stored along with the entities. A table consists of two properties: columns and rows. While rows represent records, the columns represent attributes.

C1

RIYA

DELHI

15

20

17 of 35

  • Degree: It refers to the total number of attributes that are there in the relation. The EMPLOYEE relation defined here has degree 5.
  • Relation Schema: It represents the relation’s name along with its attributes. E.g., EMPLOYEE (ID_NO, NAME, ADDRESS, ROLL_NO, AGE) is the relation schema for EMPLOYEE. If a schema has more than 1 relation, then it is known as Relational Schema.
  • Column: It represents the set of values for a certain attribute. The column ID_NO is extracted from the relation EMPLOYEE.
  • Cardinality: It refers to the total number of rows present in the given table. The EMPLOYEE relation defined here has cardinality 4.
  • Relation instance – It refers to a finite set of tuples present in the RDBMS system. A relation instance never has duplicate tuples.
  • Attribute domain – Every attribute has some predefined value and scope, which is known as the attribute domain.
  • Relation key – Each and every row consists of a single or multiple attributes. It is known as a relation key.
  • NULL Values: The value that is NOT known or the value that is unavailable is known as a NULL value. This null value is represented by the blank spaces. E.g., the MOBILE of the EMPLOYEE having ID_NO 4 is NULL.

18 of 35

Constraints in Relational Model

  • While we design a Relational Model, we have to define some conditions that must hold for the data present in a database. These are known as constraints. One has to check these constraints before performing any operation (like insertion, updating and deletion) in the database. If there occurs any kind of a violation in any of the constraints, the operation will ultimately fail.

19 of 35

  • Domain Constraints
  • The domain constraints are like attribute level constraints. Now an attribute is only capable of taking values that lie inside the domain range. For example, if a constraint ID_NO>0 is applied on the EMPLOYEE relation, inserting some negative value of ID_NO will result in failure.
  • Key Integrity
  • Each and every relation present in the database should have at least one set of attributes that uniquely defines a tuple. Those sets of attributes are known as keys. For example, ID_NO in EMPLOYEE is a key. Now, remember that no two students would be capable of having the very same ID number. Thus, a key primarily consists of these two properties:
  • It has to be unique for all the available tuples.
  • It can not consist of any NULL values.

20 of 35

  • Referential Integrity
  • Whenever one of the attributes of a relation is capable of only taking values from another attribute of the same relation or other relations, it is termed referential integrity.
  • Now, let us have the following two relations:
  • LEARNER

  • SUBJECT

  • .

ID_NO

NAME

ADDRESS

ROLL_NO

AGE

CODE_OF_BRANCH

C1

RIYA

DELHI

15

20

CS

C2

SUNITA

GURGAON

16

22

CS

C3

ASHWANI

ROHTAK

12

18

ECE

C4

PREETI

DELHI

18

25

IT

SUBJECT_NAME

SUBJECT_CODE

COMPUTER SCIENCE

CS

INFORMATION TECHNOLOGY

IT

ELECTRONICS AND COMMUNICATION ENGINEERING

ECE

CIVIL ENGINEERING

CV

21 of 35

  • The SUBJECT_CODE of LEARNER can only take the values that are present in the SUBJECT_CODE of SUBJECT, which is known as referential integrity constraint. Thus, the relation that is referencing to the other relation is known as REFERENCING RELATION (LEARNER in this case), while that relation to which the other relations refer is known as REFERENCED RELATION (SUBJECT in this case).

22 of 35

What is the Entity-Relationship Model in DBMS?

  • A high-level data model diagram is the entity-relationship model or ER Model. We depict the real-world problem in visual form in this model to make it easier for stakeholders to comprehend. The developers can also quickly grasp the system by simply looking at the ER Diagram.

23 of 35

  • Features of an Entity-Relationship Model
  • 1. Graphical Representation for Better Understanding – It is really straightforward and easy to comprehend, so developers can use it to interact with stakeholders.
  • 2. Database Design – This approach is extensively used in database design and aids database designers in the creation of databases.
  • 3. ER Diagram – The ER diagram is a visual representation of the model.

24 of 35

  • Components of an ER Diagram
  • The ER diagram is a visual representation of an ER Model. The three components of an ER diagram are as follows:
  • 1. Entities
  • An entity is a real-life concept. It could be a person, a location, or even an idea. A school management system, for example, has entities such as teachers, students, courses, buildings, departments, and so on.
  • 2. Attributes
  • An attribute is a real-world property that exists in an entity. For example, the entity teacher has properties such as teacher salary, id, age, and so on.
  • 3. Relationship
  • The relationship between two traits describes how they are linked. A teacher, for example, works for a department.

25 of 35

  • Example

26 of 35

  • The entities in the figure above are Teacher and Department. Teacher_id, Teacher_Name, Age, Salary, and Mobile Number are the characteristics of the Teacher object. Dept_name and Dept_id are the attributes of the Department entity. The relationship is used to connect the two entities, and each teacher is assigned to a department.

27 of 35

  • Pros of Entity-Relationship Model
  • 1. Simple – The ER Model is simple to construct conceptually. We can easily construct the ER Diagram for the model if we know the relationship between the entities and the attributes.
  • 2. Effective communication tool – Database designers frequently employ this model to communicate their thoughts.
  • 3. Easy conversion to any model – This model translates neatly to the relational model, and it is simple to transform the ER model into a table. This model can be transformed into a network model, a hierarchical model, and so forth.
  • Cons of Entity-Relationship Model
  • 1. No industry standard for notation – When it comes to creating an ER model, there is no industry standard. As a result, one developer may utilise notations that are unfamiliar to other developers.
  • 2. Hidden information – In the ER model, certain information may be lost or hidden. Because it is a high-level view, there is a potential that some information specifics will be buried.

28 of 35

  • What is an ER Diagram in DBMS?
  • An ER diagram is used to represent the ER Model in DBMS. An ER diagram can be used to represent an item, such as entities, relationship sets, attributes of entities, and attributes of relationship sets.
  • Entity
  • Rectangles are used to represent entities. The rectangles are provided with names that correspond to the entity set they represent.

  • Attributes
  • Entity properties are known as attributes. Ellipses are used to symbolise attributes. Each ellipse represents a single attribute and is linked to its corresponding entity or rectangle.

  • .

29 of 35

  • In case the attributes are composite, then these are separated further into a tree-like structure. The attribute of each node is then attached to it. To put it another way, composite attributes are basically represented by ellipses joined by an ellipse.

  • A double ellipse is used to represent multivalued attributes.

  • .

30 of 35

  • Dashed ellipses represent derived attributes

  • Relationship
  • Diamond-shaped boxes signify relationships. Inside the diamond box is written the name of the relationship. A line connects all the entities or rectangles that are involved in a relationship.
  • For example, Tiffany works in the Biology department. It would be represented as follows:
  •  

31 of 35

  • Cardinality and Binary Relationship
  • The term “binary relationship” refers to a relationship in which two entities are involved. The number of instances of an entity from any relationship that can be connected or associated with the relation is known as cardinality.
  • Here are the relationships found in DBMS:
  • 1. One-to-one – The relationship is denoted as ‘1:1’ when just one instance of the given entity is associated with it. Only one of the instances of each entity must be connected with the relationship, as seen in the image below. It is a representation of a one-to-one relationship.

.

32 of 35

  • 2. One-to-many – The relationship is denoted as ‘1:N’ when more than one of the instances of an entity is linked with it. The following graphic shows that the relationship can be associated with only one instance of the entity on the left and several instances of the entity on the right. It is a representation of a one-to-many relationship

  • . Many-to-one – The relationship is denoted as ‘N:1’ when more than one of the instances of the entity is associated with it. The following figure shows that the relationship can be associated with more than one instance of the entity on the left and just one instance of an entity on the right. It represents a one-to-many relationship

  • 4. Many-to-many – More than one of the instances of an entity on the right and more than one of the instances of an entity on the left can be associated with the relationship, as seen in the following image. It is a representation of a many-to-many relationship.

  • .

33 of 35

  • Participation Constraints
  • 1. Partial Participation – The relationship does not involve all entities. Single lines are used to denote partial participation.
  • 2. Total Participation – The relationship involves each entity. Double lines reflect the total number of participants.

34 of 35

  • Pros and Cons of ER Diagram
  • Pros
  • Simplicity in concept: An ERD can be easily drawn if the relationships between attributes and entities are understood.
  • The visual representation that is explicit: After reviewing the diagram, the database structure may be simply understood.
  • Effectiveness of communication: The standard symbols used for different types of data representation make it easier to understand how the database works after it’s completed.
  • Extremely adaptable: With slight adjustments, the ER data model can be simply turned into any other data model.
  • Cons
  • Relationship representation is limited: In comparison to other data models, the model has a limited number of relationships.
  • There is no depiction of data modification: Because the methods for displaying data modification in ERD are somewhat complex, the model is only useful in limited situations.
  • There isn’t an industry standard for notation: The notation standards differ depending on a developer’s preference, causing confusion while viewing the diagrams.

35 of 35

THANK YOU