0% found this document useful (0 votes)
13 views28 pages

Entittes

The Entity Relationship Model (ER Model) is a framework for identifying and representing entities and their relationships within a database, developed by Peter Chen in 1976. It utilizes ER diagrams to visually depict the logical structure of data, making it accessible for users without technical knowledge. The document also covers key concepts such as strong and weak entities, attributes, relationships, and the principles of generalization and specialization in database design.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views28 pages

Entittes

The Entity Relationship Model (ER Model) is a framework for identifying and representing entities and their relationships within a database, developed by Peter Chen in 1976. It utilizes ER diagrams to visually depict the logical structure of data, making it accessible for users without technical knowledge. The document also covers key concepts such as strong and weak entities, attributes, relationships, and the principles of generalization and specialization in database design.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Entity Relationship Model :

➢The Entity Relationship Model is a model for identifying entities to be represented in the
database and representation of how those entities are related. The ER data model specifies
enterprise schema that represents the overall logical structure of a database graphically.
➢Peter Chen developed the ER diagram in 1976. The ER model was created to provide a simple
and understandable model for representing the structure and logic of databases.
➢ER diagrams represent the E-R model in a database, making them easy to convert into relations
(tables).

➢ER diagrams provide the purpose of real-world modeling of objects which makes them intently
useful.

➢ER diagrams require no technical knowledge and no hardware support.

➢These diagrams are very easy to understand and easy to create even for a naive user.

➢It gives a standard solution for visualizing the data logically.


Symbols Used in ER Model
ER Model is used to model the logical view of the system from a data perspective which
consists of these symbols:
• Rectangles: Rectangles represent Entities in the ER Model.

• Ellipses: Ellipses represent Attributes in the ER Model.

• Diamond: Diamonds represent Relationships among Entities.

• Lines: Lines represent attributes to entities and entity sets with other relationship types.

• Double Ellipse: Double Ellipses represent Multi-Valued Attributes.

• Double Rectangle: Double Rectangle represents a Weak Entity.


Components of ER model
What is Entity?
An Entity may be an object with a physical existence – a particular person, car, house, or
employee – or it may be an object with a conceptual existence – a company, a job, or a university
course.
Entity set?
Collection or a set of all the entities share the same attributes set
or
An Entity is an object of Entity Type and a set of all entities is called an entity set. For
Example, E1 is an entity having Entity Type Student and the set of all students is called Entity
Set.
▪ An entity set that has a primary key is the strong entity set
▪ An entity set that does not have a primary key is a weak entity
Strong Entity :
A Strong Entity is a type of entity that has a key Attribute. Strong Entity
does not depend on other Entity in the Schema. It has a primary key, that
helps in identifying it uniquely, and it is represented by a rectangle. These
are called Strong Entity Types.
Weak Entity
weak entity is an entity that depends on another entity . Weak entity does
not have key attribute of their own. Double rectangle represents weak entity.
Example ER diagram to weak and Strong entity
Attributes are properties or characteristics of an entity. Attributes are used to describe the
entity. The attribute is nothing but a piece of data that gives more information about the entity.
Simple Attribute
➢Simple attributes are those attributes that cannot be divided into more attributes. Simple
attributes state the simple information about the entity such as name, roll_no, class, age, etc.

➢Simple attributes are widely used for storing information about the entity.
Composite Attribute
• When 2 or more than 2 simple attributes are combined to make an attribute then that attribute
is called a Composite attribute.

• The composite attribute is made up of multiple attributes. After combining these attributes,
the composed attributes are formed.

• Complex attributes are used where data is complex and needs to be stored in a complex
structure.
Single Valued Attribute
• The attribute with only a single value is known as a single-valued
attribute. These attributes have a single value for each instance of a
given entity.

• Mostly these attributes are used to provide the unique identity to the
multiple instances of attributes.
Multivalued Attribute
➢An attribute which can have multiple values is known as
a multivalued attribute. Multivalued attributes have multiple values
for the single instance of an entity.

➢Key of entity is associated with multiple values. It does not have only
one value. It is the opposite of the single-valued attribute.
Key Attribute
➢The attribute which has unique values for every row in the table is
known as a Key Attribute. The key attribute has a very crucial role in
the database.

➢The key attribute is a distinct and unique characteristic of the entity


that can be used to identify the entity uniquely.
Derived Attribute
➢The attribute that can be derived from the other attributes and does
not require to be already present in the database is called a Derived
Attribute.

➢Derived attributes are not stored in the Database directly. It is


calculated by using the stored attributes in the database.
Relationship
A relationship in DBMS is association between two or more entities. Entities are the
real-world objects which hold data, participate in these relationships.
Connection between different entities are represented by a diamond shapes in ER
diagrams.
Relationships enables the separation and organization of data across multiple tables
which facilitate the data management and data retrieval.
One-To-One
CREATE TABLE users (
user_id INT PRIMARY KEY,
username VARCHAR(50));
CREATE TABLE user_profiles (
profile_id INT PRIMARY KEY,
user_id INT UNIQUE,
profile_data VARCHAR(255),
FOREIGN KEY (user_id) REFERENCES users(user_id));
One –To-Many
CREATE TABLE departments (
department_id INT PRIMARY KEY,
department_name VARCHAR(50));
CREATE TABLE employees (
employee_id INT PRIMARY KEY,
employee_name VARCHAR(50),
department_id INT,
FOREIGN KEY (department_id) REFERENCES departments(department_id));
Many-To-Many
• CREATE TABLE students (
student_id INT PRIMARY KEY,
student_name VARCHAR(50));
CREATE TABLE courses (
course_id INT PRIMARY KEY,
course_name VARCHAR(50));
CREATE TABLE student_courses (
student_id INT,
course_id INT,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY (student_id) REFERENCES students(student_id),
FOREIGN KEY (course_id) REFERENCES courses(course_id));
Constraints
Constraints are the rules that we can apply on the type of data in a table. That is, we can specify the limit
on the type of data that can be stored in a particular column in a table using constraints. The available constraints
in SQL are:

➢ NOT NULL: This constraint tells that we cannot store a null value in a column. That is, if a column is specified
as NOT NULL then we will not be able to store null in this particular column any more.
➢ UNIQUE: This constraint when specified with a column, tells that all the values in the column must be unique.
That is, the values in any row of a column must not be repeated.

➢ PRIMARY KEY: A primary key is a field which can uniquely identify each row in a table. And this constraint
is used to specify a field in a table as primary key.

➢ FOREIGN KEY: A Foreign key is a field which can uniquely identify each row in a another table. And this
constraint is used to specify a field as Foreign key.

➢ CHECK: This constraint helps to validate the values of a column to meet a particular condition. That is, it helps
to ensure that the value stored in a column meets a specific condition.

➢ DEFAULT: This constraint specifies a default value for the column when no value is specified by the user.
➢Sub class:
A subclass is a class derived from the superclass. It inherits the properties
of the superclass and also contains attributes of its own.

➢Super class:
A superclass is the class from which many subclasses can be created, The
subclasses inherit the characteristics of a superclass. The superclass is also known
as the parent class or base class.
Example of super class and sub class
Inheritance

➢Inheritance is basically the process of basing a class on another class i.e to build a class on a
existing class. The new class contains all the features and functionalities of the old class in
addition to its own.
➢Inheritance in DBMS allow us to create a relationship between tables,
➢It enables us to establish a hierarchical structure among tables , where child table inherit
attributes and behaviours from their parent table .
➢This help to reduce redundancy , improve data integrity and simplify queries.
Generalization and Specialization are two essential ideas used to describe the hierarchical connections
between things in a database in the context of Enhanced Entity-Relationship (EER) diagrams.
Generalization:
Generalization is a bottom-up method used to combine lower-level entities into a higher-level object. This
approach creates a more generic entity, known as a superclass, by combining entities with similar features. By
removing duplication and arranging the data in a more organized manner, generalization streamlines the data
model.
Advantages of Generalization

➢ Cuts Down on Redundancy: Cuts down on data duplication by combining related entities into a single entity.

➢ Simplifies Schema: Combines many things into a single, clearer schema.

➢ Enhances Data Organization: By cohesively presenting related entities, it makes better organization possible.

Disadvantages of Generalization

➢ Loss of Specificity: The generic entity may take center stage over the distinctive qualities of lower-level entities.

➢ Complexity of Querying: As data becomes more abstracted, queries may get more complicated.
Specialization
specialization is a top-down method where a higher-level entity is split into two or more
lower-level entities according to their distinct qualities.
This technique, which includes splitting a single entity set into subgroups, is often
connected to inheritance, in which attributes from the higher-level entity are passed down to the
lower-level entities.
Advantages of Specialization
• Enhances Specificity: By forming specialized subgroups, it is possible to depict things in
more depth.

• Encourages Inheritance: Relationships and characteristics from higher-level entities are


passed down to lower-level entities.

• Enhances Data Integrity: Makes certain that every entity have distinct qualities relevant to
its area of expertise.
Disadvantages of Specialization

• Expands Schema Size: Adding additional entities may lead to an


increase in the schema’s complexity and size.

• Can Cause Redundancy: There might be certain characteristics that


are duplicated across specialized entities.
Difference Between Generalization and Specialization

• Generalization works in Bottom-Up • Specialization works in top-down approach.


approach. • In Specialization, size of schema gets
• In Generalization, size of schema gets increased.
reduced. • We can apply Specialization to a single
• Generalization is normally applied to entity .
group of entities. • Specialization can be defined as process of
• Generalization can be defined as a process creating subgrouping within an entity set
of creating groupings from various entity • Specialization is reverse of Generalization.
sets Specialization is a process of taking a subset
• In Generalization process, what actually of a higher-level entity set to form a lower-
happens is that it takes the union of two or level entity set.
more lower-level entity sets to produce a • Specialization process starts from a single
higher-level entity sets. entity set and it creates a different entity set
• Generalization process starts with the by using some different features.
number of entity sets and it creates high-
level entity with the help of some
common features. • In Specialization, a higher entity is split to
• In Generalization, the difference and form lower entities.
similarities between lower entities are
ignored to form a higher entity.

You might also like