A â€˜thingâ€™ or an â€˜objectâ€™ that is distinguishable from all the other objects. Each entity has a set of properties. For example, each person in an enterprise is an entity with properties person-id, name,age etc.
Set of entities of the same type that share the same properties or attributes. For example, employees of a store.Attributes maybe single or multi-valued, simple or composite,derived.
Is an association among several entities. For example,a car is owned by a person. Relationships can be recursive. For example, a student helps a student. Both belong to the same entity set of students. Relationships can have descriptive attributes. For example, the relationship â€˜car owned by a personâ€™ can have attribute â€˜sinceâ€™.
Set of relationships of the same type. For example, a relationship set of â€˜ownsâ€™ between two entities, owners and cars. Relationships can have mapping cardinality i.e. they can be one to one, many to one, one to many and many to many.Entity sets can have full participation or partial participation in a relationship. The participation of an entity set E in a relationship set R is said to be full if every entity in E participates in at least one relationship in R. If only some entities in E participate in relationships in R, the participation of entity set E in relationship R is said to be partial.
A key is a set of attributes whose values allow us to uniquely distinguish entities from each other.
K is a superkey of R if values for K are sufficient to identify a unique tuple of each possible relation r(R)
Superkey K is a candidate key if K is minimal i.e. it has the least number of attributes possible.
One of the candidate keys is selected to be the primary key.
Relationships can involve multiple entities. For example, a
professor guides a student for multiple projects.
Design of ER Diagrams
|Rectangles||Represent entity sets|
|Diamonds||Represent relationship sets|
|Lines||Link attributes to entity sets and entity sets to|
|Double ellipses||Represent multi-valued attributes|
|Dashed ellipses||Denote derived attributes|
|Double lines||Indicate total participation of an entity in a|
|Double rectangles||Represent weak entity sets|
A Simple ER Diagram Construction
Consider an Entity relationship diagram that consists of two entities called customer and loan related through a binary relationship called borrower. The attributes associated with the customer are customer-id, customer-name, customer-street and customer-city. The attributes associated with loan are loan-number and amount. Attributes of an entity set that are members of primary key must be underlined.
A directed line (â†’) from a relationship set towards an entity set also indicates a key constraint i.e. it specifies that the relationship is either a one-to-one or many-to-one relationship set from the first entity to the entity directed by the arrow.
An undirected line (â€”) from the relationship set to the entity set specifies that the relationship is either a many-to-many or one-to-many relationship set from the first entity to the directed entity.
Here, the relationship borrower may be a many to many or a one-to-many relationship from customer to loan as it is connected without an arrow. The â€˜Customer-idâ€™ is the primary key that uniquely identifies the entities of the set â€˜customerâ€™ and the â€˜Loan-numberâ€™ is the primary key that uniquely identifies the entities of the set â€˜loanâ€™.