An entity is ‘thing’ or ‘object’ in the real world that is distinguishable from all other objects. Object may be person, place, event etc.
Types of Entity
- Strong Entity: Entities having its own attribute as primary keys are called strong entity. For example, STUDENT has STUDENT_ID as primary key. Hence it is a strong entity.
- Weak Entity: Entities which cannot form their own attribute as primary key are known weak entities. These entities will derive their primary keys from the combination of its attribute and primary key from its mapping entity.
An entity set refers to a collection of entities of the same kind. Each entity in Entity set have the same set of attributes and the set of attributes will distinguish it from other Entity Sets. No other entity set will have exactly the same set of attributes. Some of the attributes of an entity set may overlap with other entity sets.
Comparison between Strong Entity and Weak Entity
|It has its own primary key.||It does not save sufficient attributes to form a primary key on its own.|
|Total participation in the relationship may or may not exist.||Total participation in the identifying relationship always exist.|
|The member of strong entity set is called as dominant entity set.||The member of weak entity set is called as subordinate entity set.|
|Primary key is one of its attribute which uniquely identifies its member.||The Primary key of weak entity set is a combination of partial key and primary key of the strong entity set.|
|The line connecting strong entity set with the relationship is single.||The line connecting weak entity set with the identifying relationship is double.|
Attributes define the properties of a data object of entity. For example if student is an entity, his ID, name , address, date of birth , class are are its attributes.
Types of Attributes
- Multi- valued
Simple attribute is which cannot be divided into subparts. It has a single component with an independent existence. For example Age, Salary etc.
A composite attribute is defined as an attribute composed of multiple components each with an independent existence. For example Address is a composite attribute which can be further subdivided into street, city, pincode.
It holds single value for particular entity. For example age of student.
A multivalued a ttribute isone that holds multiple values for a single entity. For Example, a student entity can have multiple values for the Hobby attribute such as reading, dancing, painting.
- Derived attribute
An attribute that can be derived from other known attributes is known as derived attribute. For example age of employees can be derived from date of birth attribute.
Differences between entities must be expressed in terms of attributes known as keys.These facilitate us to uniquely identify each entity in a set and thus distinguishes entities from each other.
Types of Keys
- Super Key
- Candidate Key
- Primary Key
- Foreign Key
- Super Key
A superkey is a set of one or more attributes which put together enable us to identify uniquely an entity in the entity set.
For example in entity set Employee, shown in fig. given below, Super Keys are
- (ID, Name, Salary, Reg. No.)
- (ID, Name, Reg. No.)
- (ID) etc.
All combinations can identify data uniquely.
- Candidate Key
A superkey may contain extraneous attributes and we are often intrest in the smallest superkey. A superkey for which no subset is a superkey is called candidate key. For Example ID and Registration no. are candidate key.
- Primary Key
It is a candidate key that is chosen by the database designer as the principle means of identifying entities within an entity set. For example In Entity set Employee either Reg. No. is primary key or ID is primary key.
An attribute or set of attributes, within one relation that matches the candidate key of some relation. A foreign key is an attribute in any entity set which is also a Primary Key in any other entity set. For Example Dept ID : This is an attribute in entity set. Employee and also a primary Key in entity set Department. Thus it is a foreign key in Employee.