Thursday, November 3, 2016

Entity and Its Types

Entity and its Types – Strong Entity, Weak Entity, Composite Entity

Entity – 

An entity is an object that are represented in the database. For example Mohit, Vasu, CSE306 etc.
An entity is represented or defined by set of attributes. Attributes are the properties used to describe an entity. For example, a STUDENT entity may have a Name, Roll number, Class, Marks etc. where STUDENT is the entity and name roll number class marks are the attributes.

Types of Entity – 

  1. Strong Entity Types
  2. Recursive Entity Types
  3. Weak Entity Types
  4. Composite Entity Types or Associative Entity Types
  5. SuperType and SubType Entities

Notations Of different Entity Type in ER Diagram 

 Entity-2(entity and its types)Entity
Strong Entity Type(Entity and its Types)Strong Entity Type
weak entity type-1(entity and its types)Weak Entity Type
Recursive Entity Set(entity and its types)Recursive Entity Type
Composite or Associative Entity(entity and its types)Composite Entity Type (or)
Associative Entity
 Subtypes and supertypes-Entity and its Types Subtypes and Supertypes

Strong Entity Type – are the entities which has a key attribute in its attribute list or a set that has a primary key. The strong entity type is also called regular entity type. For Example,
Strong Entity Type(Entity and its Types)

The Student’s unique RollNo will identify the students. So, RollNo is set to be the Primary Key of the STUDENT entity, & Hence STUDENT is a strong entity type because of its key attribute.
Recursive Entity Type – It is also called Self Referential Relationship Entity Type. It is an entity type with foreign key referencing to same table or itself. Recursive Entity Type occurs in a unary relationship.
For example, a supervisor and subordinate relationship sets – One Supervisor can supervise multiple subordinates but each subordinate reporting to atmost one supervisor.
Recursive Entity Set(Entity and its Types)

In example b) An employee supervises another employee. Let the employee who supervises another one is manager. So, Manager supervises employees. But a manager is also an employee, whose details are in the employee entity. So, to implement this, a foreign key of the employee’s manager number would be held in each employee record i.e “supssn”.
So, the employee entity will contain its attributes as –
  • Employee ID (subssn)
  • Employee FirstName
  • Employee Lastname
  • Employee DateofBirth
  • and Manager Number (i.e. employee number of the employee’s manager) – (supssn)
The next figure will clear you the employee entity as a recursive entity –
Recursive Entity example(Entity and its Types)
If M:M ==> Reports_To(supssn,subssn)
then 2 tables are made.
Weak Entity Type –

weak entity type(entity and its types)
Entity Type with no key or Primary Key are called weak entity Type.
The Tuples of weak entity type may not be possible to differentiate using one attribute of weak entity.For every weak entity, there should be unique OWNER entity type. In the below example, CHILD is a WEAK entity type and Employee is the OWNER entity type.
Example of weak entity type is –
weak entity type(entity and its types)
Children Entity is depending upon Strong Entity Employee(as it has a unique ID named SSN). The relationship is established to associate children with their parents for insurance coverage.
Attributes of CHILDREN entity are-
  • CNAME (name of Child)
  • Age of Child
  • Type of Insurance
So, None of the attributes of CHILDREN does not give a unique ID to the entity. And the CHILDREN Entity has to depend on EMPLOYEE entity for identification.
The next table will clear you the child entity as a weak entity and so is represented with employee id(SSN) –
SSNCNAMEAGEGENDER
E1A8M
E2A10M
E1B10F
E3B10F
CHILD_BELONGS_TO(SSN,CNAME,AGE,GENDER)
Maximum number of tables = 2
Minimum number of tables = 2
Some Points about weak entity Type –
1) Weak entity Type should always combines with weak relationship set for 
   database schema relation.
 
2) Relationship between OWNER ENTITY Type and Weak Entity Type is also 
   partial. 

3) Participation between weak entity Type and relationship is always TOTAL

4) Cardinality can be Many to Many or One to Many.
Composite Entities –
If a Many to Many relationship exist then we must eliminate it by using composite entities. Composite Entities are the entities which exists as a relationship as well as an entity. The many to many relationship will be converted to 1 to many relationship.
Composite Entities are also called Bridge Entities, because they acts like a bridge between the two entities which have many to many relationship.
Bridge or Composite entity composed of the primary keys of each of the entities to be connected.
A composite entity is represented by a diamond shape with in a rectangle in an ER Diagram.

Supertypes and Subtypes Entities –
A subtype is a subprouping of the entities in an entity type that is meaningful to the organisation. For example, In a University, a STUDENT is an entity type. Two subtypes of STUDENT entity are
  • GRADUATE STUDENT
  • UNDERGRADUATE STUDENT
A supertype is a generic entity type that has a relationship with one or more sub-types. In the above example, STUDENT entity is a supertype.

2 comments: