Showing posts with label Entity Relationship Model. Show all posts
Showing posts with label Entity Relationship Model. Show all posts

Saturday, 14 June 2014

Generalization Aggregation

Post By: Hanan Mannan
Contact Number: Pak (+92)-321-59-95-634
-------------------------------------------------------

Generalization Aggregation

ER Model has the power of expressing database entities in conceptual hierarchical manner such that, as the hierarchical goes up it generalize the view of entities and as we go deep in the hierarchy it gives us detail of every entity included.
Going up in this structure is called generalization, where entities are clubbed together to represent a more generalized view. For example, a particular student named, Mira can be generalized along with all the students, the entity shall be student, and further a student is person. The reverse is called specialization where a person is student, and that student is Mira.

Generalization

As mentioned above, the process of generalizing entities, where the generalized entities contain the properties of all the generalized entities is called Generalization. In generalization, a number of entities are brought together into one generalized entity based on their similar characteristics. For an example, pigeon, house sparrow, crow and dove all can be generalized as Birds.
[Image: Generalization]

Specialization

Specialization is a process, which is opposite to generalization, as mentioned above. In specialization, a group of entities is divided into sub-groups based on their characteristics. Take a group Person for example. A person has name, date of birth, gender etc. These properties are common in all persons, human beings. But in a company, a person can be identified as employee, employer, customer or vendor based on what role do they play in company.
[Image: Specialization]
Similarly, in a school database, a person can be specialized as teacher, student or staff; based on what role do they play in school as entities.

Inheritance

We use all above features of ER-Model, in order to create classes of objects in object oriented programming. This makes it easier for the programmer to concentrate on what she is programming. Details of entities are generally hidden from the user, this process known as abstraction.
One of the important features of Generalization and Specialization, is inheritance, that is, the attributes of higher-level entities are inherited by the lower level entities.
[Image: Inheritance]
For example, attributes of a person like name, age, and gender can be inherited by lower level entities like student and teacher etc.

Posted By MIrza Abdul Hannan2:53:00 pm

ER Diagram Representation

Post By: Hanan Mannan
Contact Number: Pak (+92)-321-59-95-634
-------------------------------------------------------

ER Diagram Representation

Now we shall learn how ER Model is represented by means of ER diagram. Every object like entity, attributes of an entity, relationship set, and attributes of relationship set can be represented by tools of ER diagram.

Entity

Entities are represented by means of rectangles. Rectangles are named with the entity set they represent.
[Image: Entities in a school database]

Attributes

Attributes are properties of entities. Attributes are represented by means of eclipses. Every eclipse represents one attribute and is directly connected to its entity (rectangle).
[Image: Simple Attributes]

If the attributes are composite, they are further divided in a tree like structure. Every node is then connected to its attribute. That is composite attributes are represented by eclipses that are connected with an eclipse.
[Image: Composite Attributes]

Multivalued attributes are depicted by double eclipse.
[Image: Multivalued Attributes]

Derived attributes are depicted by dashed eclipse.
[Image: Derived Attributes]

Relationship

Relationships are represented by diamond shaped box. Name of the relationship is written in the diamond-box. All entities (rectangles), participating in relationship, are connected to it by a line.

BINARY RELATIONSHIP AND CARDINALITY

A relationship where two entities are participating, is called a binary relationship. Cardinality is the number of instance of an entity from a relation that can be associated with the relation.
  • One-to-one
    When only one instance of entity is associated with the relationship, it is marked as '1'. This image below reflects that only 1 instance of each entity should be associated with the relationship. It depicts one-to-one relationship
  • [Image: One-to-one]
  • One-to-many
    When more than one instance of entity is associated with the relationship, it is marked as 'N'. This image below reflects that only 1 instance of entity on the left and more than one instance of entity on the right can be associated with the relationship. It depicts one-to-many relationship
  • [Image: One-to-many]
  • Many-to-one
    When more than one instance of entity is associated with the relationship, it is marked as 'N'. This image below reflects that more than one instance of entity on the left and only one instance of entity on the right can be associated with the relationship. It depicts many-to-one relationship
  • [Image: Many-to-one]
  • Many-to-many
    This image below reflects that more than one instance of entity on the left and more than one instance of entity on the right can be associated with the relationship. It depicts many-to-many relationship
  • [Image: Many-to-many]

PARTICIPATION CONSTRAINTS

  • Total Participation: Each entity in the entity is involved in the relationship. Total participation is represented by double lines.
  • Partial participation: Not all entities are involved in the relation ship. Partial participation is represented by single line.
[Image: Participation Constraints]

Posted By MIrza Abdul Hannan2:53:00 pm

ER Model : Basic Concepts

Post By: Hanan Mannan
Contact Number: Pak (+92)-321-59-95-634
-------------------------------------------------------

ER Model : Basic Concepts

Entity relationship model defines the conceptual view of database. It works around real world entity and association among them. At view level, ER model is considered well for designing databases.

Entity

A real-world thing either animate or inanimate that can be easily identifiable and distinguishable. For example, in a school database, student, teachers, class and course offered can be considered as entities. All entities have some attributes or properties that give them their identity.
An entity set is a collection of similar types of entities. Entity set may contain entities with attribute sharing similar values. For example, Students set may contain all the student of a school; likewise Teachers set may contain all the teachers of school from all faculties. Entities sets need not to be disjoint.

Attributes

Entities are represented by means of their properties, called attributes. All attributes have values. For example, a student entity may have name, class, age as attributes.
There exist a domain or range of values that can be assigned to attributes. For example, a student's name cannot be a numeric value. It has to be alphabetic. A student's age cannot be negative, etc.

TYPES OF ATTRIBUTES:

  • Simple attribute:
    Simple attributes are atomic values, which cannot be divided further. For example, student's phone-number is an atomic value of 10 digits.
  • Composite attribute:
    Composite attributes are made of more than one simple attribute. For example, a student's complete name may have first_name and last_name.
  • Derived attribute:
    Derived attributes are attributes, which do not exist physical in the database, but there values are derived from other attributes presented in the database. For example, average_salary in a department should be saved in database instead it can be derived. For another example, age can be derived from data_of_birth.
  • Single-valued attribute:
    Single valued attributes contain on single value. For example: Social_Security_Number.
  • Multi-value attribute:
    Multi-value attribute may contain more than one values. For example, a person can have more than one phone numbers, email_addresses etc.
These attribute types can come together in a way like:
  • simple single-valued attributes
  • simple multi-valued attributes
  • composite single-valued attributes
  • composite multi-valued attributes

ENTITY-SET AND KEYS

Key is an attribute or collection of attributes that uniquely identifies an entity among entity set.
For example, roll_number of a student makes her/him identifiable among students.
  • Super Key: Set of attributes (one or more) that collectively identifies an entity in an entity set.
  • Candidate Key: Minimal super key is called candidate key that is, supers keys for which no proper subset are a superkey. An entity set may have more than one candidate key.
  • Primary Key: This is one of the candidate key chosen by the database designer to uniquely identify the entity set.

Relationship

The association among entities is called relationship. For example, employee entity has relation works_at with department. Another example is for student who enrolls in some course. Here, Works_at and Enrolls are called relationship.

RELATIONSHIP SET:

Relationship of similar type is called relationship set. Like entities, a relationship too can have attributes. These attributes are called descriptive attributes.

DEGREE OF RELATIONSHIP

The number of participating entities in an relationship defines the degree of the relationship.
  • Binary = degree 2
  • Ternary = degree 3
  • n-ary = degree

MAPPING CARDINALITIES:

Cardinality defines the number of entities in one entity set which can be associated to the number of entities of other set via relationship set.
  • One-to-one: one entity from entity set A can be associated with at most one entity of entity set B and vice versa.
    [Image: One-to-one relation]
  • One-to-many: One entity from entity set A can be associated with more than one entities of entity set B but from entity set B one entity can be associated with at most one entity.
    [Image: One-to-many relation]
  • Many-to-one: More than one entities from entity set A can be associated with at most one entity of entity set B but one entity from entity set B can be associated with more than one entity from entity set A.
    [Image: Many-to-one relation]
  • Many-to-many: one entity from A can be associated with more than one entity from B and vice versa.
    [Image: Many-to-many relation]

Posted By MIrza Abdul Hannan2:52:00 pm