Docsity

Entity-Relationship Diagram, Study notes of Database Management Systems (DBMS)

Partial preview of the text

Download Entity-Relationship Diagram and more Study notes Database Management Systems (DBMS) in PDF only on Docsity!

DATABASE

MANAGEMENT SYSTEMS

ENTITY RELATIONSHIP MODEL

ER MODEL

  • (^) What is the ER Model?
  • (^) Components of ERD
  • (^) Steps to Create an ERD
  • (^) Sample ERD

Components of ERD

  • (^) Entities
  • (^) Attributes
  • (^) Keys
  • (^) Relationships Entity: An entity is an object or concept about which you want to store information. It is represented using rectangle. Weak Entity: It is defined by a foreign key relationship with another entity as it cannot be uniquely identified by its own attributes alone. It is represented using double rectangle. Entity Entity

Components of ERD Attributes: If a Student is an Entity, then student's roll no., student's name, student's age, student's gender etc., will be its attributes. Simple attribute: The attributes with values that are atomic and cannot be broken down further are simple attributes. For example, student's gender. Composite attribute: A composite attribute is made up of more than one simple attribute. For example, student's address will contain, house no., street name, pincode etc. Simple Attribute Composite Attribute value value value

Components of ERD Keys are very important part of Relational database model. They are used to establish and identify relationships between tables and also to uniquely identify any record or row of data inside a table. A Key can be a single attribute or a group of attributes, where the combination may act as a key. Primary Key: It is a key that can uniquely identify each record in a table. Foriegn Key: A Foreign Key is a field (or collection of fields) in one table that refers to the Primary Key in another table. Key_Attribute Key_Attribute

Components of ERD Relationships: Relationships are represented by diamond-shaped box. Name of the relationship is written inside the diamond-box. All the entities (rectangles) participating in a relationship, are connected to it by a line. Weak Relationship: A weak entity is the entity which can't be fully identified by its own attributes and takes the foreign key as an attribute (generally it takes the primary key of the entity it is related to) in conjunction. Relation ship Relation ship

Components of ERD Cardinalities: There are four types of Cardinalities as follows: One to One: When a single instance of an entity is associated with a single instance of another entity then it is called one to one relationship. For example, a person has only one passport and a passport is given to one person. One to Many: When a single instance of an entity is associated with more than one instances of another entity then it is called one to many relationship. For example – a customer can place many orders but a order cannot be placed by many customers.

Components of ERD Many to One: When more than one instances of an entity is associated with a single instance of another entity then it is called many to one relationship. For example – many students can study in a single college but a student cannot study in many colleges at the same time. Many to Many Relationship: When more than one instances of an entity is associated with more than one instances of another entity then it is called many to many relationship. For example, a can be assigned to many projects and a project can be assigned to many students.

Steps to Create an ERD

Sample ERD

QUESTION Given the basic ER and relational models, which of the following is INCORRECT? A. An attribute of an entity can have more than one value B. An attribute of an entity can be composite C. In a row of a relational table, an attribute can have more than one value D. In a row of a relational table, an attribute can have exactly one value or a NULL value

ANSWER Option: C Explanation: The term ‘entity’ belongs to ER model and the term ‘relational table’ belongs to relational model. A and B both are true. ER model supports both multivalued and composite attributes See this for more details. (C) is false and (D) is true. In Relation model, an entry in relational table can can have exactly one value or a NULL.

ANSWER Option: B

QUESTION An entity that does not have sufficient attributes to form a primary key is termed a


A. Strong entity set B. Variant set C. Weak entity set D. Variable set