Skip to the content.

Data Models in DBMS

Data Model gives us an idea that how the final system will look like after its complete implementation. It defines the data elements and the relationships between the data elements. Data Models are used to show how data is stored, connected, accessed and updated in the database management system. Here, we use a set of symbols and text to represent the information so that members of the organisation can communicate and understand it.

Entity Realtionship Model

An ER model describes the structure of a database with the help of a diagram, which is known as Entity Relationship Diagram (ER Diagram).An ER model is a design or blueprint of a database that can later be implemented as a database. An ER diagram shows the relationship among entity sets. An entity set is a group of similar entities and these entities can have attributes.

ER-diagram

In above diagram,

3 components of ER-diagram:

1. Entity:

Entity is a real-world thing. It can be a person, place, or even a concept. Example: Teachers, Students, Course, Building, Department, etc are some of the entities of a School Management System.

Weak Entity:

2. Attribute:

An entity contains a real-world property called attribute. This is the characteristics of that attribute. Example: The entity teacher has the property like teacher id, salary, age, etc. 4 Types of Attributes:

Key Attribute:

Composite Attribute:

Multivalued Attribute:

Derived Attribute:

3. Relationship:

Relationship tells how two entities are related. Example: Teacher works for department.Here, “works for” is relationship.4 types of Relationship.

One to One:

One to Many:

Many to One:

Many to Many:

Total Participation:

Partial Participation:

Participation ER-diagram

DBMS Generalization:

Generalisation is a process in which common attributes of more than one entities form new entity.This newly formed entity is called a generalized entity.Lets look with an example,

The ER diagram before generalization looks like this: Participation ER-diagram

The ER diagram after generalization looks like this: Participation ER-diagram

DBMS Specialization:

In specialization, an entity is divided into sub-entities based on their characteristics. It is a top-down approach where higher level entity is specialized into two or more lower level entities. For example, Consider an entity employee which can be further classified as sub-entities Technician, Engineer & Accountant because these sub entities have some distinguish attributes.

specialization ER-diagram

DBMS Aggregation:

Aggregation is a process in which a single entity alone is not able to make sense in a relationship so the relationship of two entities acts as one entity.

Aggregation ER-diagram

In real world example, we know Manager not only manages employee working under them but also project as well.In such scenario, if entity “Manager” makes “manages” relationship with either “Employee” or “Project” entity alone then it will not make any sense because he has to manage both.In these cases the relationship of two entities acts as one entity. In our example, the relationship “Works-On” between “Employee” & “Project” acts as one entity that has a relationship “Manages” with the entity “Manager”.

Relational Model:

In Relational Model, Data and relationships are represented by collection of inter-related tables.

Hierarchical Model:

This database model organises data into a tree-like-structure, with a single root, to which all the other data is linked. The heirarchy starts from the Root data, and expands like a tree, adding child nodes to the parent nodes.

Hierarchial model

Network Model:

This is an extension of the Hierarchical model. In this model data is organised more like a graph, and are allowed to have more than one parent node.

network model

Constraints in DBMS:

constraints enforce limits to the data or type of the data that can be inserted/updated/deleted from a table.The whole purpose of constraints is to maintain the data integrity during an update/delete/insert into a table.

Types of Constraints:

NOT NULL:

UNIQUE:

DEFAULT:

CHECK:

Key Constraints:

PRIMARY KEY:

Domain Constraints:

Mapping Constraints:

Assuming, that a customer orders more than once, the below relation represents one to many relation.

CREATE TABLE Customer (
customer_id int PRIMARY KEY NOT NULL,
first_name varchar(20) NOT NULL UNIQUE,
last_name varchar(20) NOT NULL UNIQUE,
Age int NOT NULL check(Age>15),
Address varchar(20) Default "durgapur"
);

CREATE TABLE Order (
order_id int PRIMARY KEY NOT NULL,
customer_id int,
order_details varchar(50),
constraint fk_Customers foreign key (customer_id) 
       references dbo.Customer
);