0% found this document useful (0 votes)
4 views24 pages

DBMS Unit 1

A database is an organized electronic collection of data that allows efficient data management through a Database Management System (DBMS). Users interact with databases in various roles, such as Database Administrators, naive users, and application programmers, each with specific responsibilities and access levels. The database approach offers advantages like data integrity, security, and efficient management, but also has disadvantages including implementation costs and complexity.

Uploaded by

swagi says
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views24 pages

DBMS Unit 1

A database is an organized electronic collection of data that allows efficient data management through a Database Management System (DBMS). Users interact with databases in various roles, such as Database Administrators, naive users, and application programmers, each with specific responsibilities and access levels. The database approach offers advantages like data integrity, security, and efficient management, but also has disadvantages including implementation costs and complexity.

Uploaded by

swagi says
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

What is a Database?

A database is an organized collection of data that is stored and managed electronically. It allows
for efficient retrieval, updating, insertion, and deletion of data. Databases are typically structured
in tables that are related to one another, and they use database management systems (DBMS) to
ensure data integrity, security, and efficient querying.
Databases can store various types of data such as text, numbers, images, or even complex objects
like videos and documents. They are widely used in applications ranging from websites to
enterprise systems and can handle large amounts of information.

Types of Database Users


A Database User is defined as a person who interacts with data daily, updating, reading, and
modifying the given data. Database users can access and retrieve data from the database through
the Database Management System (DBMS) applications and interfaces. Database users are
categorized based on their interaction with the database. There are seven types of database users
in DBMS. Below mentioned are the types of database users:
1. Database Administrator (DBA)
A Database Administrator (DBA) is a person or team who defines the schema and controls the 3
levels of the database. The DBA will then create a new account ID and password for the user if
he/she needs to access the database. The DBA is also responsible for providing security to the
database and allowing only authorized users to access/modify it. The DBA is responsible for
problems such as security breaches and poor system response time.
 DBA also monitors the recovery and backup and provides technical support.
 The DBA has a DBA account in the DBMS which is called a system or superuser
account.
 DBA repairs damage caused due to hardware and/or software failures.
 DBA is the one having privileges to perform DCL (Data Control Language) operations
such as GRANT and REVOKE, to allow/restrict a particular user from accessing the
database.
2. Naive / Parametric End Users
Parametric End Users are the unsophisticated who don’t have any DBMS knowledge but they
frequently use the database applications in their daily life to get the desired results. For example,
Railway’s ticket booking users are naive users. Clerks in any bank is a naive user because they
don’t have any DBMS knowledge but they still use the database and perform their given task.
3. A System Analyst
A system Analyst is a user who analyzes the requirements of parametric end users. They check
whether all the requirements of end users are satisfied.
4. Sophisticated Users
Sophisticated users can be engineers, scientists, and business analysts, who are familiar with the
database. They can develop their database applications according to their requirement. They
don’t write the program code but they interact with the database by writing SQL queries directly
through the query processor.
5. Database Designers
Data Base Designers are the users who design the structure of a database which includes tables,
indexes, views, triggers, stored procedures, and constraints which are usually enforced before the
database is created or populated with data. He/she controls what data must be stored and how the
data items are related. It is the responsibility of Database Designers to understand the
requirements of different user groups and then create a design that satisfies the needs of all the
user groups.
6. Application Programmers
Application Programmers also referred to as System Analysts or simply Software Engineers, are
the back-end programmers who write the code for the application programs. They are the
computer professionals. These programs could be written in Programming languages such as
Visual Basic, Developer, C, FORTRAN, COBOL, etc. Application programmers design, debug,
test, and maintain a set of programs called “canned transactions” for Naive (parametric) users to
interact with the database.
7. Casual Users / Temporary Users
Casual Users are the users who occasionally use/access the database but each time when they
access the database they require new information, for example, a Middle or higher-level
manager.
8. Specialized users
Specialized users are sophisticated users who write specialized database applications that do not
fit into the traditional data-processing framework. Among these applications are computer-aided-
design systems, knowledge-base and expert systems, etc.

Characteristics of Database
The database approach includes key features that ensure data accuracy, consistency, integrity,
security, etc. Let us now understand some of the important characteristics of the Database
Approach separately.
The characteristics of the Database are as follows:
Data Organization and self-describing nature of Database system
The database approach stores data in a structured and organized manner. It uses the database
management system to create, design, and maintain data logically and consistently. The database
approach also comes with the characteristic of a self-describing nature of a database system. That
is, the database not only contains the data and the tables but a thorough description of the entire
database in the form of metadata.
For example, the database of any e-commerce company contains data on its customers and
vendors in tables linked with foreign keys.
Integrity Of Data
Data integrity means the accuracy and consistency of data over its entire lifecycle. The database
approach emphasizes data integrity through the use of various methods such as data validation,
data normalization, the use of queries, and referential integrity. These techniques ensure that data
is accurate, consistent, and free from errors or duplicates. Data Integrity prevents human errors,
transfer errors and data verification errors.
For example, the database of any e-commerce company maintains the accuracy and consistency
of data inserted in tables because of the property of Data Integrity.
Data Independence
Data independence is another vital characteristic of the database approach. Data independence
means that the database structure and design are independent of the application programs that use
it. Any modifications to the database structure will not affect the application programs and vice
versa. This property makes modifying and updating the database easier without disrupting the
application software's functioning.
For example, the database of an online food ordering company can be modified without affecting
the consumer side of the website because of its data independence.
Data Security
Data security is a critical aspect of the database approach. A database management system
provides various security measures such as authentication, authorization, and encryption to
protect data from unauthorized access, tampering, or data breaches. This makes it easier to
identify the user and control who has access to data and what they can do with it, thus making
the data more secure.
The database approach also provides a good backup and data recovery feature. This is achieved
with techniques like database backups, replication, and transaction logs.
For example, the data of customers in the database of any ecommerce company has a high
backup facility and the data is securely stored in the database.
Data Consistency with centralized data management
All the data in the database approach is stored in a single centralized location rather than in
separate files. This characteristic of centralized data management contributes to data consistency
by storing data in a standardized format. Also, the database is updated and manipulated from a
single location. The database stored at a centralized computer system can be accessed through an
internet connection. Thus coordination of data becomes a lot easier and simpler here.
Sharing of Data
Data sharing is one of the essential aspects of the database approach. Here, data can be shared
among multiple users and applications simultaneously. It also reduces the need to store duplicate
data in various locations, which can lead to inconsistencies and errors.
Data sharing with multiple users can occur with techniques like concurrency and locking control.
This enhances collaboration and efficiency. During locking locks specific data from being
accessed by any other user while it is being updated, concurrency control handles the access to
data by numerous users by applying the strategy of time stamping and pessimistic and optimistic
concurrency control.
For example, in an online food ordering website multiple users can add food to their cart and
order food at the same time allowing multiple users to access the same database.
Query and Report Flexibility
The database approach also offers users query and report flexibility, allowing them to fetch and
analyze data efficiently. Queries can be used to perform CRUD operations like creating, reading,
updating, and deleting actions or filtering data according to the requirement.
The flexibility of the report means the database approach offers tools to generate customized
interactive reports in formats like graphs, tables, and charts that analyze data more easily. Here
we can define our dimension metrics for the data.

Advantages of the Database Approach


The database approach has many advantages that lead to better business results and a competitive
advantage in today's data-driven world. Some of the advantages of the database approach are as
follows.
Efficient data management: Following the database approach makes it easier to manage and
update data as it is stored in a centralized memory, thus allowing faster access to data. Hence
efficient data management is achieved.
Refined data quality: The database approach has tools that enforce data integrity and
consistency, thus ensuring the accuracy of data being inserted in the database. This increases the
quality of data by reducing the risk of errors.
Enhanced productivity: With the tools offered by the database approach, the data can be
accessed faster and easier, thus reducing the time and effort required to fetch and analyze the
information. This, in turn, enhances productivity by decreasing the time spent on data
management.
Better decision-making: With the database approach, data can be analyzed in various ways
allowing us to analyze every option, thus leading to better decision-making.
Increased data security: With the database approach, we can control the access to data
ensuring that the sensitive data is well protected from unauthorized access. This increases data
security, preventing any data breaches.
Scalability: The database storage can be expanded or contracted per the memory and data
processing requirement. This scalability benefits growing businesses to adapt their databases
according to their needs.

Disadvantages of using the Database Approach


The disadvantages of database approach are:
Cost of implementation and maintenance: Implementing and maintaining the database
approach can be quite expensive, especially for small, growing businesses with limited
resources. There is the cost of hardware, software, licensing, etc.
Increased complexity of database system: The database approach can be very complex
regarding queries. Even maintaining data consistency can be challenging. Also, with the
advancement in technology, the complexity may increase.
Need for a data analyst: The complexity and involvement of technology in the database
approach introduces the need for a specialized expert or a data analyst, which can be pretty
expensive for the business.
Risk of data loss: Databases can be subjected to vulnerable security threats such as malware,
hacking, etc.
Increased dependence on technology: The database system is highly dependent on technology
in the database approach. The disruption of technology can anytime lead to the failure of the
entire database, thereby resulting in data loss or corruption.
The relational model uses a collection of tables to represent both data and the relationships
among those data. Each table has multiple columns, and each column has a unique name. Tables
are also known as relations.
Important Terminologies
Attribute: Attributes are the properties that define an entity. e.g.; ROLL_NO, NAME, ADDRESS
Relation Schema: A relation schema defines the structure of the relation and represents the name
of the relation with its attributes. e.g.; STUDENT (ROLL_NO, NAME, ADDRESS, PHONE,
and AGE) is the relation schema for STUDENT. If a schema has more than 1 relation, it is called
Relational Schema.
Tuple: Each row in the relation is known as a tuple.
Degree: The number of attributes in the relation is known as the degree of the relation. The
STUDENT relation defined above has degree 5.
Cardinality: The number of tuples in a relation is known as cardinality. The STUDENT relation
defined above has cardinality 4.
Column: The column represents the set of values for a particular attribute. The column
ROLL_NO is extracted from the relation STUDENT.
Domain : It consists of set of legal values
A Database Management System (DBMS) is software that enables users to create, manage, and
manipulate databases. It provides an interface for interacting with the data stored in a database,
allowing users to perform operations such as querying, updating, and administering data.
Key functions of a DBMS include:
 Data Storage and Retrieval: Efficiently storing and retrieving data.
 Data Manipulation: Allowing users to insert, update, and delete data.
 Data Security: Protecting data through access controls and user permissions.
 Data Integrity: Ensuring accuracy and consistency of data through constraints and rules.
 Backup and Recovery: Providing mechanisms to back up data and recover it in case of
failures.
Advantages:
 Data Integrity and Consistency: DBMS enforces data integrity constraints, ensuring that
the data remains accurate and consistent across the database.
 Data Security: It provides access controls and authentication mechanisms to protect
sensitive data from unauthorized access.
 Data Redundancy Control: DBMS reduces data redundancy by centralizing data storage,
helping to avoid duplication.
 Efficient Data Management: It offers powerful tools for data manipulation and querying,
enabling efficient data management and retrieval.
 Backup and Recovery: Most DBMSs include built-in tools for data backup and recovery,
ensuring data can be restored in case of corruption or loss.
 Multi-user Support: DBMS allows multiple users to access and work with the database
concurrently, managing transactions to prevent conflicts.
 Scalability: Many DBMSs can handle increasing amounts of data and users, making them
suitable for growing organizations.
Disadvantages:
 Complexity: Setting up and managing a DBMS can be complex and requires skilled
personnel, leading to a steep learning curve.
 Cost: Commercial DBMS software can be expensive, including licensing, maintenance,
and infrastructure costs.
 Performance Overhead: The added layers of abstraction and security can lead to
performance overhead, especially for simple applications.
 Potential for Data Loss: While DBMSs provide backup and recovery options, improper
management can still lead to data loss.
 Vendor Lock-in: Relying on a specific DBMS can lead to vendor lock-in, making it
difficult to switch to another system without significant effort and cost.
 Maintenance and Upkeep: Regular maintenance, updates, and tuning are required to
ensure optimal performance and security.

Database Schema:
The schema is the blueprint or the structure of the database. It defines how data is organized,
how relationships between data are managed, and the types of data (tables, fields, relationships,
constraints, etc.) that will be stored in the database.
It is static and typically doesn't change frequently. The schema describes the structure of the
entire database, including:
Database Instance:
The instance refers to the actual data stored in the database at a specific point in time. It
represents the state of the database at any moment.
It is dynamic, meaning the instance can change frequently as data is added, updated, or deleted.
Query Optimizer: It executes the instruction generated by DML Compiler.
Authorization Manager: It ensures role-based access control, i.e,. checks whether the particular
person is privileged to perform the requested operation or not.
Integrity Manager: It checks the integrity constraints when the database is modified.
Transaction Manager: It controls concurrent access by performing the operations in a scheduled
way that it receives the transaction. Thus, it ensures that the database remains in the consistent
state before and after the execution of a transaction.
File Manager: It manages the file space and the data structure used to represent information in
the database.
Buffer Manager: It is responsible for cache memory and the transfer of data between the
secondary storage and main memory.
Data Dictionary: It contains the information about the structure of any database object. It is the
repository of information that governs the metadata.
Introduction of ER Model


Peter Chen developed the ER diagram in 1976. The ER model was created to provide a simple
and understandable model for representing the structure and logic of databases. It has since
evolved into variations such as the Enhanced ER Model and the Object Relationship Model
The Entity Relational Model is a model for identifying entities to be represented in the database
and representation of how those entities are related. The ER data model specifies enterprise
schema that represents the overall logical structure of a database graphically.
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.
Why Use ER Diagrams In DBMS?
 ER diagrams represent the E-R model in a database, making them easy to convert
into relations (tables).
 ER diagrams provide the purpose of real-world modeling of objects which makes
them intently useful.
 ER diagrams require no technical knowledge and no hardware support.
 These diagrams are very easy to understand and easy to create even for a naive user.
 It gives a standard solution for visualizing the data logically.
Symbols Used in ER Model
ER Model is used to model the logical view of the system from a data perspective which consists
of these symbols:
 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
ER Model consists of Entities, Attributes, and Relationships among Entities in a Database
System.
Components of ER Diagram

What is Entity?
An Entity may be an object with a physical existence – a particular person, car, house, or
employee – or it may be an object with a conceptual existence – a company, a job, or a university
course.
What is Entity Set?
An Entity is an object of Entity Type and a set of all entities is called an entity set. For Example,
E1 is an entity having Entity Type Student and the set of all students is called Entity Set. In ER
diagram, Entity Type is represented as:

Entity Set

We can represent the entity set in ER Diagram but can’t represent entity in ER Diagram because
entity is row and column in the relation and ER Diagram is graphical representation of data.
Types of Entity
There are two types of entity:
1. Strong Entity
A Strong Entity is a type of entity that has a key Attribute. Strong Entity does not depend on
other Entity in the Schema. It has a primary key, that helps in identifying it uniquely, and it is
represented by a rectangle. These are called Strong Entity Types.
2. Weak Entity
An Entity type has a key attribute that uniquely identifies each entity in the entity set. But some
entity type exists for which key attributes can’t be defined. These are called Weak Entity types .
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.
Strong Entity and Weak Entity

What is 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.

Attribute

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.

Key Attribute

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.
Composite Attribute

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.

Multivalued Attribute

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.

Derived Attribute

The Complete Entity Type Student with its Attributes can be represented as:
Entity and Attributes

Relationship Type and Relationship Set


A Relationship Type represents the association between entity types. For example, ‘Enrolled in’
is a relationship type that exists between entity type Student and Course. In ER diagram, the
relationship type is represented by a diamond and connecting the entities with lines.

Entity-Relationship Set

A set of relationships of the same type is known as a relationship set. The following relationship
set depicts S1 as enrolled in C2, S2 as enrolled in C1, and S3 as registered in C3.
Relationship Set

Degree of a Relationship Set


The number of different entity sets participating in a relationship set is called the degree of a
relationship set.
1. Unary Relationship: When there is only ONE entity set participating in a relation, the
relationship is called a unary relationship. For example, one person is married to only one person.

Unary Relationship

2. Binary Relationship: When there are TWO entities set participating in a relationship, the
relationship is called a binary relationship. For example, a Student is enrolled in a Course.

Binary Relationship
3. Ternary Relationship: When there are three entity sets participating in a relationship, the
relationship is called a ternary relationship.
4. N-ary Relationship: When there are n entities set participating in a relationship, the
relationship is called an n-ary relationship.
What is Cardinality?
The number of times an entity of an entity set participates in a relationship set is known
as cardinality . Cardinality can be of different types:
1. One-to-One: When each entity in each entity set can take part only once in the relationship,
the cardinality is one-to-one. Let us assume that a male can marry one female and a female can
marry one male. So the relationship will be one-to-one.
the total number of tables that can be used in this is 2.

one to one cardinality

Using Sets, it can be represented as:

Set Representation of One-to-One

2. One-to-Many: In one-to-many mapping as well where each entity can be related to more than
one entity and the total number of tables that can be used in this is 2. Let us assume that one
surgeon department can accommodate many doctors. So the Cardinality will be 1 to M. It means
one department has many Doctors.
total number of tables that can used is 3.

one to many cardinality

Using sets, one-to-many cardinality can be represented as:

3. Many-to-One: When entities in one entity set can take part only once in the relationship set
and entities in other entity sets can take part more than once in the relationship set, cardinality
is many to one. Let us assume that a student can take only one course but one course can be
taken by many students. So the cardinality will be n to 1. It means that for one course there can
be n students but for one student, there will be only one course.
The total number of tables that can be used in this is 3.

many to one cardinality

Using Sets, it can be represented as:


Set Representation of Many-to-One

In this case, each student is taking only 1 course but 1 course has been taken by many students.
4. Many-to-Many: When entities in all entity sets can take part more than once in the
relationship cardinality is many to many. Let us assume that a student can take more than one
course and one course can be taken by many students. So the relationship will be many to many.
the total number of tables that can be used in this is 3.

many to many cardinality

Using Sets, it can be represented as:


Many-to-Many Set Representation

In this example, student S1 is enrolled in C1 and C3 and Course C3 is enrolled by S1, S3, and
S4. So it is many-to-many relationships.
Participation Constraint
Participation Constraint is applied to the entity participating in the relationship set.
1. Total Participation – Each entity in the entity set must participate in the relationship. If each
student must enroll in a course, the participation of students will be total. Total participation is
shown by a double line in the ER diagram.
2. Partial Participation – The entity in the entity set may or may NOT participate in the
relationship. If some courses are not enrolled by any of the students, the participation in the
course will be partial.
The diagram depicts the ‘Enrolled in’ relationship set with Student Entity set having total
participation and Course Entity set having partial participation.
Total Participation and Partial Participation

Using Set, it can be represented as,

Set representation of Total Participation and Partial Participation

Every student in the Student Entity set participates in a relationship but there exists a course C4
that is not taking part in the relationship.
How to Draw ER Diagram?
 The very first step is Identifying all the Entities, and place them in a Rectangle, and
labeling them accordingly.
 The next step is to identify the relationship between them and place them
accordingly using the Diamond, and make sure that, Relationships are not
connected to each other.
 Attach attributes to the entities properly.
 Remove redundant entities and relationships.
 Add proper colors to highlight the data present in the database.

Extended Entity Relationship (ER) Features


As the complexity of data increased in the late 1980s, it became more and more difficult to use
the traditional ER Model for database modelling. Hence some improvements or enhancements
were made to the existing ER Model to make it able to handle the complex applications better.
Hence, as part of the Extended ER Model, along with other improvements, three new concepts
were added to the existing ER Model:

1. Generalization
2. Specialization
3. Aggregation

1. Generalization
 Generalization is the process of extracting common properties from a set of entities and
create a generalized entity from it.
 Generalization is a "bottle-up approach" in which two or more entities can be combined
to form a higher level entity if they have some attributes in common.
 Subclasses are combined to make a superclass.
 Generalization is used to emphasize the similarities among lower-level entity set and to
hide differences in the schema.

Example:
Consider we have 3 sub entities Car, Bus and Motorcycle. Now these three entities can be
generalized into one higher-level entity (or super class) named as Vehicle.

2. Specialization
 Specialization is opposite of Generalization.
 In Specialization, an entity is broken down into sub-entities based on their
characteristics.
 Specialization is a "Top-down approach" where higher level entity is specialized into
two or more lower level entities.
 Specialization is used to identify the subset of an entity set that shares some
distinguishing characteristics
 Specialization can be repeatedly applied to refine the design of schema.
 Normally, the superclass is defined first, the subclass and its related attributes are
defined next, and relationship set are then added.
 Depicted by triangle component labeled ISA

Example:
Vehicle entity can be a Car, Bus or Motorcycle.

3. Aggregation
 Aggregation is used when we need to express a relationship among relationships.
 Aggregation is an abstraction through which relationships are treated as higher level
entities.
 Aggregation is a process when a relationship between two entities is considered as a
single entity and again this single entity has a relationship with another entity.

Note: Basic E-R model can't represent relationships involving other relationships.

Example:

 Consider a ternary relationship works_on between Employee, Branch and Job.


 An Employee works on a particular job at a particular branch.
Suppose we want to assign a manager for jobs performed by an employee at a branch (i.e. want
to assign managers to each employee, job, branch combination)

 Need a separate manager entity-set.


 Relationship between each manager, employee, branch and job entity.

With Aggregation the ER diagram can be represented as:

 An employee works on a particular job at a particular branch.


 An employee, branch, job combination may have an associated manager.
What are the different types of Keys in DBMS?
Keys are of seven broad types in DBMS:

1. Candidate Key
2. Primary Key
3. Foreign Key
4. Super Key
5. Alternate Key
6. Composite Key
7. Unique Key

1. Primary Key
The primary key refers to a column or a set of columns of a table that helps us
identify all the records uniquely present in that table. A table can consist of
just one primary key. Also, this primary key cannot consist of the same values
reappearing/repeating for any of its rows. All the values of a primary key have
to be different, and there should be no repetitions.

The PK (PRIMARY KEY) constraint that we put on a column/set of columns


won’t allow these to have a null value or a duplicate. Any table can consist of
only a single primary key constraint. A foreign key (explained below) that
refers to it can never change the values present in the primary key.

2. Super Key
A super key refers to the set of all those keys that help us uniquely identify all
the rows present in a table. It means that all of these columns present in a
table that can identify the columns of that table uniquely act as the super
keys.

A super key is a candidate key’s superset (candidate key has been explained
below). We need to pick the primary key of any table from the super key’s set
so as to make it the table’s identity attribute.

3. Candidate Key
The candidate keys refer to those attributes that identify rows uniquely in a
table. In a table, we select the primary key from a candidate key. Thus, a
candidate key has similar properties as that of the primary keys that we have
explained above. In a table, there can be multiple candidate keys.

4. Alternate Key
As we have stated above, any table can consist of multiple choices for the
primary key. But, it can only choose one. Thus, all those keys that did not
become a primary key are known as alternate keys.

5. Foreign Key
We use a foreign key to establish relationships between two available tables.
The foreign key would require every value present in a column/set of columns
to match the referential table’s primary key. A foreign key helps us to maintain
data as well as referential integrity.

6. Composite Key
The composite key refers to a set of multiple attributes that help us uniquely
identify every tuple present in a table. The attributes present in a set may not
be unique whenever we consider them separately. Thus, when we take them
all together, it will ensure total uniqueness.

You might also like