0% found this document useful (0 votes)
2 views

Dbms Module 2

The document outlines various types of keys used in database management, including candidate keys, primary keys, foreign keys, alternate keys, composite keys, and super keys, each with distinct characteristics and examples. It also explains the concept of Entity-Relationship Diagrams (ERDs), detailing their components such as entities, attributes, and relationships, along with their representations. Additionally, it describes different types of relationships (one-to-one, one-to-many, many-to-one, and many-to-many) and attributes (key, composite, multivalued, and derived) within the context of ER modeling.

Uploaded by

budhiabarik66
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Dbms Module 2

The document outlines various types of keys used in database management, including candidate keys, primary keys, foreign keys, alternate keys, composite keys, and super keys, each with distinct characteristics and examples. It also explains the concept of Entity-Relationship Diagrams (ERDs), detailing their components such as entities, attributes, and relationships, along with their representations. Additionally, it describes different types of relationships (one-to-one, one-to-many, many-to-one, and many-to-many) and attributes (key, composite, multivalued, and derived) within the context of ER modeling.

Uploaded by

budhiabarik66
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

KEYS:

It is used to uniquely identify any record or row of data from the table. It is also used to establish
and identify relationships between tables.

Types Of Keys :

 Candidate Key
 Primary Key
 Super Key
 Alternate Key
 Foreign Key
 Composite Key

1. Candidate Key :
A candidate key is a minimal set of attributes that can uniquely identify a record in a table.
A table may have multiple candidate keys, but only one is chosen as the primary key.

Characteristics:

 Must be unique and non-null.


 Each candidate key can potentially be chosen as the primary key.

Example: In a Student table, both StudentID and Email might serve as candidate keys,
provided each is unique.

2. Primary Key :
A primary key is a unique identifier for a record within a table. It ensures that each record
can be uniquely identified and that no two records have the same primary key value.

Characteristics:

 Must be unique for each record.


 Cannot be null.
 There can be only one primary key in a table.

Example: In a Student table, StudentID might be the primary key.


3. Foreign Key
A foreign key is an attribute (or a set of attributes) in one table that references the
primary key of another table. It establishes and enforces a link between the two tables.

Characteristics:

o Can accept duplicate values.


o Can have null values, depending on the database design.

Example: In an Enrollment table, StudentID might be a foreign key that references


the StudentID in the Student table.

4. Alternate Key
An alternate key is any candidate key that is not chosen as the primary key. It serves as a
secondary unique identifier for records.

Characteristics:

Must be unique and non-null.

Example: If StudentID is chosen as the primary key, then Email might be an alternate key.

5. Composite Key

A composite key (or compound key) is a primary key that consists of two or more attributes.
It is used when a single attribute is not sufficient to uniquely identify a record.

Characteristics:

Each attribute in the composite key contributes to the uniqueness of the record.

Example: In an OrderDetails table, a combination of OrderID and ProductID might serve as a


composite primary key.

6. Super Key

A super key is any set of attributes that can uniquely identify a record in a table. It may
contain additional attributes beyond those necessary for uniqueness.

Characteristics:

Includes primary keys and any other attributes that can ensure uniqueness.
Example: In a Student table, {StudentID, Email} could be a super key if StudentID alone is the
primary key.

ER DIAGRAM :-
An Entity-Relationship Diagram (ERD) is a visual representation of the Entity-Relationship
model used in database design. It helps to outline the structure of a database by showing the
entities, their attributes, and the relationships between them.

The Entity Relationship Diagram explains the relationship among the entities present in the
database. ER models are used to model real-world objects like a person, a car, or a company
and the relation between these real-world objects. In short, the ER Diagram is the structural
format of the database.

Symbols Used in ER Diagram :

 Rectangles: Rectangles represent Entities in the ER Model.


 Ellipses: Ellipses represent Attributes in the ER Model.
 Diamond: Diamonds represent Relationships among Entities.
 Lines: Lines represent attributes to entities and entity sets with other relationship
types.
 Double Ellipse: Double Ellipses represent Multi-Valued Attributes.
 Double Rectangle: Double Rectangle represents a Weak Entity.

Components of ER Diagram :
Entities: These are objects or things in the real world that have a distinct existence and can be
identified uniquely.

For example, in a university database, entities might include "Student," "Professor," and
"Course."

Entity Set : An Entity is an object of Entity Type and a set of all entities is called an entity
set.

Strong Entity : A strong entity (or regular entity) is an entity that can be uniquely identified
by its own attributes alone. It does not rely on any other entity to provide its uniqueness.

Weak Entity: A weak entity is an entity that cannot be uniquely identified by its own
attributes alone.

For Example, A company may store the information of dependents (Parents, Children,
Spouse) of an Employee. But the dependents can’t exist without the employee. So Dependent
will be a Weak Entity Type and Employee will be Identifying Entity type for Dependent,
which means it is Strong Entity Type .

A weak entity type is represented by a Double Rectangle. The participation of weak entity
types is always total. The relationship between the weak entity type and its identifying strong
entity type is called identifying relationship and it is represented by a double diamond.
Attributes :
Attributes are the properties that define the entity type.

For example, Roll_No, Name, DOB, Age, Address, and Mobile_No are the attributes that
define entity type Student.

In ER diagram, the attribute is represented by an oval.

Types of Attributes:

1. Key Attribute:
The attribute which uniquely identifies each entity in the entity set is called the key attribute.

For example, Roll_No will be unique for each student. In ER diagram.

The key attribute is represented by an oval with underlying lines.


2. Composite Attribute:
An attribute composed of many other attributes is called a composite attribute.

For example, the Address attribute of the student Entity type consists of Street, City, State, and
Country.

In ER diagram, the composite attribute is represented by an oval comprising of ovals.

3. Multivalued Attribute :
An attribute consisting of more than one value for a given entity.

For example, Phone_No (can be more than one for a given student).

In ER diagram, a multivalued attribute is represented by a double oval.

4. Derived Attribute :
An attribute that can be derived from other attributes of the entity type is known as a derived
attribute.

e.g.; Age (can be derived from DOB).

In ER diagram, the derived attribute is represented by a dashed oval.


Relationship:
A relationship is used to describe the relation between entities. Diamond or rhombus is used to
represent the relationship.

a. 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.

b. 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.
c. 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.

d. 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.

You might also like