Saturday, July 27, 2013

SQL Server : E-R Model


Database design representation will be done using E-R Model.

Entity :

An entity is a any object, place, person, concept o activity about which an enterprise records data.
Example :

Name

Price

Description

Keyboard800Computer Accessories
Mouse200Computer Accessories

Attributes :

An attribute is the characteristic property of an existing entity. Attribute type is the property of entity type, and attribute instance is the property of entity instance.
An ellipse always represents the attribute.

Example :
What is Entity-Relational Mode in SQL Server | E-R Model Works

Relationship among data:

A relationship is defined as "an association among entities". A relationship type is an association of entity types. While a relationship instance is an association of entity instances.
A relationship may associate an entity with itself. Several relationships may exist between the same entities.
The three different types of relationships recognized among various data stored in the database are:
  1. One - to - one
  2. One - to - Many (or Many - to - one )
  3. Many - to - Many

One-to-One :

Consider for example a set of students in a class. Each student can have only oneRoll number. Similaryly each role number can be associated with on Student. This is the case of a one-to-one relationship.
One-to-one relationship in sql server


Many-to-One :

One student can register for only one particular course at a time, whereas a number of students could register for the same course.
Many-to-Many relationship in sql server


Many-to-Many :

A vendor can sell a number of items and many vendors can sell a particular item.
Many-to-Many relationship in sql server