content

Unit 2: Entity-Relationship Models

Important Questions

Q1. Define entity and entity type.

A. An entity is a piece of data that’s uniquely identifiable within the database and usually represents something from the real world.

An Entity type is a collection of entities with general characteristics.

For example, a database of a corporate company has entity types such as employees, departments, etc. In DBMS, every entity type contains a set of attributes that explain the entity.

Javatpoint

GeeksForGeeks

Q2. What is an entity set?

A. An entity set is a collection of similar types of entities that share the same attributes.

For example, all students of a school are a entity set of Student entities.

GeeksForGeeks

Q3. What is an attribute?

A. An attribute is a property that describes the entity. For example, in a customer database, the attributes might be name, address, and phone number.

In a relational data model, it is depicted as a column.

KnowledgeHut

Q4. What is the difference between prime and non-prime attributes?

A. Prime attributes are attributes that are part of a candidate key (Unique Key).

Non-prime attributes are attributes that are not part of any candidate key (Unique Key).

TechnoGeeksCS

Q5. Explain a strong and weak entity set with an example.

A. In database design, an entity set is a collection of entities that share common characteristics.

Entities are objects or concepts that have existence and can be described with a set of attributes or properties. There are two types of entity sets:

Characteristics Strong Entity Set Weak Entity Set
Unique Identifier Yes (e.g. Employee ID) No (relies on another entity)
Independent Existence Yes (can exist alone) No (exists with another entity)
Example Employee (e.g. John Smith) Order Item (e.g. Book in Order 1)
ER Model Representation Rectangles Double Rectangles
Key Attributes Has its own primary key Has a partial key (foreign key)
Existence Dependency Exists independently Exists dependent on another entity
Identification Identified by its own attributes Identified by its own and another entity’s attributes

GeeksForGeeks

Q6. Explain the type of attributes.

A. There are different types of attributes:

GeeksForGeeks

Q7. Define the following with examples:

Table 1: | Employee ID | Name | Department | | — | — | — | | 101 | John Smith | Sales | | 102 | Jane Doe | Marketing | | 103 | Bob Johnson | IT |

Table 2: | Order ID | Customer ID | Order Date | | — | — | — | | 1 | 101 | 2022-01-01 | | 2 | 101 | 2022-01-15 | | 3 | 102 | 2022-02-01 |

Customer ID Name Address
101 John Smith 123 Main St
102 Jane Doe 456 Elm St

Table 3: | Order ID | Product ID | Quantity | | — | — | — | | 1 | 101 | 2 | | 1 | 102 | 1 | | 2 | 101 | 3 |

Q8. What are the symbols used in ER diagrams?

A. check Q9

Q9. What is the notation of the ER diagram? Give an example.

A. Refer to:

A. University: Image

Library: Image

Q11. What are Relationship types, set and degrees of relation?

A. Relationship type:

Relationship set:

Degree of relationship:

Cardinality:

There are three main types of relationships:

One-to-One (1:1) Relationship

In a 1:1 relationship, each entity in one entity set is related to only one entity in another entity set.

Suppose we have two entity sets: Employee and Employee Details. Each employee has only one set of details, and each set of details belongs to only one employee.

Employee ID Name Department
101 John Smith Sales
102 Jane Doe Marketing
103 Bob Johnson IT
Employee ID Address Phone Number
101 123 Main St 123-456-7890
102 456 Elm St 987-654-3210
103 789 Oak St 555-123-4567

In this example, the Employee ID attribute in the Employee entity set is related to the Employee ID attribute in the Employee Details entity set. This is a 1:1 relationship because each employee has only one set of details, and each set of details belongs to only one employee.

One-to-Many (1:N) Relationship

In a 1:N relationship, each entity in one entity set is related to multiple entities in another entity set.

Suppose we have two entity sets: Customer and Order. Each customer can place multiple orders, but each order belongs to only one customer.

Customer ID Name Address
101 John Smith 123 Main St
102 Jane Doe 456 Elm St
103 Bob Johnson 789 Oak St
Order ID Customer ID Order Date
1 101 2022-01-01
2 101 2022-01-15
3 102 2022-02-01
4 103 2022-03-01
5 101 2022-04-01

In this example, the Customer ID attribute in the Customer entity set is related to the Customer ID attribute in the Order entity set. This is a 1:N relationship because each customer can place multiple orders, but each order belongs to only one customer.

Source: