Wednesday 25 May 2016

Entity Relationship in Database

A. Entity Set

Entity set is something or the objects that exist in the real world are different from other objects, have the attributes constituent, and is a system builder. Example, people who work in companies is an entity. Entity has valued attributes (values), ex: 000-11-3452 is a parent of a number of workers (number attribute holding workers). In addition, a worker also has the date of birth. Here the date of birth is an attribute of the entity is domiciled workers aligned with the attributes of the parent number of workers.

Entity has several types of attributes such as:

  1. Simple attributes: an entity whose attributes can not be divided into smaller parts.
  2. Composite attributes: attributes that can be broken down into several components. For example: name attribute can be divided into first name, middle name, and last name and address attributes.
  3. Single-valued attribute: entity whose attributes can contain only one value. Ex number of workers holding.
  4. Multi-valued attribute: entity whose attributes can contain zero, one or more than one value. For example: telephone attributes, so a worker can have zero, one, or more telephone.
  5. Derived attributes: entity whose attributes can be derived from other attributes. For example: the attribute age can be determined from the date of birth and date at that time.

B. Relational

The relationship is a relationship between two or more different entities. Such as in the above example the human entity has a relationship with an entity that addresses "lived in". In designing the data base should all existing entities have relationships with other entities, at least one. If there is an entity in the database that does not have a relationship with any other entity, then there will be errors in the design. Usually unrelated entities will be eliminated. Kinds of relationships include:
  1. One to one: An entity A is paired with exactly one entity B. Similarly, the entity B is also paired with exactly one entity A. Examples of entities that are related to the entity's student thesis in one to one.
  2. One to many: An entity A is paired many (zero or more) by the entity in the B. While entity B is only paired with exactly one entity in A. Example: a student entity related to the entity in relation to faculty supervisor. Relationships occurring one to many. Because a student has only one supervisor. While a teacher may have more than one student guidance.
  3. Many to one: An entity A is paired with exactly one entity in B. While entities B can be paired in many (zero or more) by the entity in the A. (like one to many simply reversed meaning).
  4. Many to many: An entity A is paired many (zero or more) by the entity in the B. And entity B can also pair up many (zero or more) by the entity in the A. Example: a student entity related to the entity in relation KRS course. The relation is many to many. That is, a student can take a lot of subjects, while one subject could be taken by some students.

C. Primary Key

As mentioned, that the entity is an object that is different from the other objects. Then each entity must have attributes that can distinguish between objects to each other. For example, the human entities, these entities do not have attributes that can differentiate between human objects one with another human objects. However, if the human being an employee (employee entity appears) then the object of the man and the other man as a member of the entity's employees will have the attributes that differentiate, the NIP.
Attribute is called the key. every man may not have the same NIP.

Key can consist of multiple attributes, commonly referred to as candidate keys. However, in practice as much as possible key consists of only one attribute. This is to facilitate the processing of data. Well, to get the key from the candidate key (combination of several attributes), select the most unique attributes of the entity (no value in the same attribute) and can distinguish these entities with other entities. If you've got it, the key is what is referred to as the primary key.

For example there is a candidate key a name, NIP, and date of birth. Then it needs to be sorted, which is the most unique attributes of the three attributes. Attribute names are not unique, because there is the possibility of two entities that workers have identical names. Similarly, birthday, attributes, so it could be two entities worker has the same birth date. Only NIP attributes are definitely different from each worker entity.

See Also : Normalization in Database

D. Foreign Key

Previously, it has been discussed that the entities in the database must have a relationship with another entity. Therefore, an entity that has a relationship with another entity must include the primary key of the entity in connection with it. Loading is not always the primary key in the two related entities. But enough on the entity in need. For example, an employee entity with primary key NIP. This entity has a working relationship with the entity with primary key part of the working parts ID. To be able to connect the two entities is the entity need not enter the working parts of the entity's primary key workers into one of its attributes. But it was the entity that workers enter the primary key of the entity part of the work (employment section ID).

Process holds the primary key of another entity to the entity attribute is also called the foreign key.

There is some foundation loading the primary key of an entity to another entity related. This foundation wear characteristics used relations.

  1. One to one: A entity is associated with one-to one entity B, then entity A primary key is loaded into the entity B or opposite.
  2. Many to one: entity A to entity B is related to many-to-one then the primary key of entity B is loaded into the entity A.
  3. Many to many: The entity A related to entity B is many to many then loading theprimary key of each entity will involve a new entity.

E. Entity-Relationship Diagram 

ER diagrams are used to create a database model. Then they invented the system of the model database. As for the various components in the ER diagram is:
  1. Rectangle: represent entities
  2. Elliptical: represent attributes
  3. Rhombus: represent relationships between entities
  4. Line: represents the link between the attribute
  5. Double ellipse: represents an attribute that has a lot of value
  6. Dashed ellipses: attribute represents the derivative
  7. Double line: represents total participation of an entity in a relationship
  8. Rectangular double: weak entity
There are two types of entities, the first one is a powerful entity is an entity that has a primary key. The second is a weak entity is an entity that does not have a primary key. Strong and weak entities will be discussed more in the matter of normalization.

Here is an example ER diagram in the case of customers who buy goods in bulk from warehouse suppliers.


Exercise 
Make an model of database from library system. Define entity - any entity that is in it. Attributes of constituent entities are also described. Determine primary key entity a strong. And relations among entities. After that try to describe the model with ERD!

This Is The Oldest Page


EmoticonEmoticon