2. About – ER
.MODEL
Entity relationship model also called e-r model and it
is a high level model.
This model is used to define the data elements and
relationship for a specified system.
It develops a conceptual design for the database. It
also develops a very simple and easy to design view of
data.
In ER modeling, the database structure is portrayed
as a diagram called an entity-relationship diagram.
5. Entity -
An entity may be any object, class, person or place.
In the ER diagram, an entity can be represented as
rectangles.
6. W
eakEntity
-
An entity that depends on another entity called a
weak entity.
The weak entity doesn't contain any key attribute of
its own.
The weak entity is represented by a double
rectangle.
7. Attribute -
The attribute is used to describe the property of
an entity.
For example - id, age, contact number, name, etc.
can be attributes of a student.
8. K
e
yAttribute
-
The key attribute is used to represent the main
characteristics of an entity.
It represents a primary key.
The key attribute is represented by an oval shape with
the text underlined.
10. MultivaluedAttribute
-
An attribute can have more than one value.
These attributes are known as a multivalued
attribute.
The double oval is used to represent multivalued
attribute.
12. Relationship -
A relationship is used to describe the relation
between entities.
Diamond shape is used to represent the
relationship.
There are two types one is strong relation and
second is weak relation.
Strong relationship represented by a single diamond
where weak relationship represented by double
diamond
13. T
ypesofrelationship
-
1.One-to-One Relationship
When only one instance of an entity is associated
with the relationship, then it is known as one to one
relationship.
For example, A female can marry to one male,
and a male can marry to one female.
14. 2.One-to-many relationship
When only one instance of the entity on the left, and
more than one instance of an entity on the right
associates with the relationship then this is known as a
one-to-many relationship.
For example, Scientist can invent many inventions, but
the invention is done by the only specific scientist.
15. 3.Many-to-one relationship
When more than one instance of the entity on the left,
and only one instance of an entity on the right associates
with the relationship then it is known as a many-to-one
relationship.
For example, Student enrolls for only one course, but a
course can have many students.
16. 4.Many-to-many relationship
When more than one instance of the entity on the left,
and more than one instance of an entity on the right
associates with the relationship then it is known as a many-
to-many relationship.
For example, Employee can assign by many projects and
project can have many employees.
17. KKEYS
• SUPER KEY…………….STUD NO, {STUD NO,STUD NAME}, {STUD
NO,STUD_AGE} ETC.
• CANDIDATE KEY…………STUD_NO………STUD_AGE.
• PRIMARY KEY……………..STUD NO.
• ALTERNATE KEY…………..STUD_AGE
• FOREIGN KEY…………..STUD NO LINKING BOTH TABLES.
18. Super Key: The set of attributes which can uniquely identify a tuple is known as Super Key. For Example,
STUD_NO, (STUD_NO, STUD_NAME) etc.
Adding zero or more attributes to candidate key generates super key.
A candidate key is a super key but vice versa is not true.
Candidate Key: The minimal set of attribute which can uniquely identify a tuple is known as candidate key. For
Example, STUD_NO in STUDENT relation.
The value of Candidate Key is unique and non-null for every tuple.
There can be more than one candidate key in a relation. For Example, STUD_NO is candidate key for relation
STUDENT.
The candidate key can be simple (having only one attribute) or composite as well. For Example, {STUD_NO,
COURSE_NO} is a composite candidate key for relation STUDENT_COURSE.
Note – In Sql Server a unique constraint that has a nullable column, allows the value ‘null‘ in that column only
once. That’s why STUD_PHONE attribute as candidate here, but can not be ‘null’ values in primary key attribute.
Primary Key: There can be more than one candidate key in relation out of which one can be chosen as the
primary key. For Example, STUD_NO, as well as STUD_PHONE both, are candidate keys for relation STUDENT but
STUD_NO can be chosen as the primary key (only one out of many candidate keys).
Alternate Key: The candidate key other than the primary key is called an alternate key. For Example, STUD_NO,
as well as STUD_PHONE both, are candidate keys for relation STUDENT but STUD_PHONE will be alternate key
(only one out of many candidate keys).
Foreign Key: If an attribute can only take the values which are present as values of some other attribute, it will
be a foreign key to the attribute to which it refers. The relation which is being referenced is called referenced
relation and the corresponding attribute is called referenced attribute and the relation which refers to the
referenced relation is called referencing relation and the corresponding attribute is called referencing attribute.
The referenced attribute of the referenced relation should be the primary key for it. For Example, STUD_NO in
STUDENT_COURSE is a foreign key to STUD_NO in STUDENT relation.
It may be worth noting that unlike, Primary Key of any given relation, Foreign Key can be NULL as well as may
contain duplicate tuples i.e. it need not follow uniqueness constraint.
For Example, STUD_NO in STUDENT_COURSE relation is not unique. It has been repeated for the first and third
tuple. However, the STUD_NO in STUDENT relation is a primary key and it needs to be always unique and it
cannot be null.