DATABASE MANAGEMENT SYSTEM

ATTRIBUTES AND KEYS 

Attributes:

Definition: An attribute is a characteristic or property of an entity. In the context of a relational database, an attribute represents a column in a table.

Example: If you have a "Student" entity, attributes could include "StudentID," "FirstName," "LastName," and "Age." Each of these represents a specific piece of information about a student.

Types of Attributes 

Simple Attribute:

A simple attribute is indivisible and cannot be further divided into smaller components.

Example: In a "Person" entity, the "FirstName" attribute is a simple attribute.

Composite Attribute:

A composite attribute is composed of multiple smaller sub-parts, each with its own meaning.

Example: The "Address" attribute may be composed of sub-parts such as "Street," "City," and "PostalCode."

Derived Attribute:

A derived attribute is one whose value can be derived or computed from other attributes in the database.

Example: The "Age" attribute can be derived from the "DateOfBirth" attribute.

Multi-valued Attribute:

A multi-valued attribute can hold multiple values for a single entity.

Example: In an "Employee" entity, the "Skills" attribute could be multi-valued, representing various skills possessed by that employee.

Key Attribute:

A key attribute is used as part of a key, such as a primary key or a foreign key, to uniquely identify instances of an entity or establish relationships between tables.

Example: In a "Product" entity, the "ProductID" attribute is a key attribute.

Single-valued Attribute:

A single-valued attribute can hold only one value for a given instance of an entity.

Example: The "PhoneNumber" attribute for a "Customer" entity is typically single-valued.

Composite Key Attribute:

A composite key attribute is formed by combining two or more attributes to create a unique identifier for an entity.

Example: In a "CompositeKeyExample" entity, the combination of "Attribute1" and "Attribute2" forms a composite key attribute.

Null Attribute:

An attribute that can have a null (missing or undefined) value.

Example: The "MiddleName" attribute for a "Person" entity may be null if the middle name is not provided.

Multivalued Dependency Attribute:

An attribute that depends on a set of other attributes, and changing one of those attributes affects the values of the multivalued attribute.

Example: In a "Project" entity, the "TeamMembers" attribute may be multivalued, depending on the "ProjectID."

Keys :

In Database Management Systems (DBMS), keys are crucial components that help establish relationships between tables and maintain the integrity of the data. Different types of keys serve various purposes within a relational database. 

Types of Keys 

Primary Key:

Definition: A primary key is a unique identifier for a record in a table. It ensures that each row in the table can be uniquely identified.

Characteristics: Unique, not null, and commonly used for indexing.

Example: In the STUDENT table, ID can be the primary key since it is unique for each student. In the STUDENT table, we even attributes like Student_Name and Address.

 

Foreign Key:

Definition: A foreign key is a column or a set of columns in a table that refers to the primary key of another table. It establishes a link between the two tables.

Purpose: Supports relationships between tables.

Example: If you have a "Course" table, and you want to link it to the "Student" table, you might have a "StudentID" column in the "Course" table that is a foreign key referencing the "StudentID" in the "Student" table.

Composite Key:

Definition: A composite key is a combination of two or more columns to uniquely identify a record in a table.

Purpose: Provides a unique identifier when a single column cannot.

Example: Instead of having a single "ID" as the key, you might use a combination of "DepartmentCode" and "EmployeeID" as a composite key for an "Employee" table within a department.

Super Key:

Definition: A super key is a set of one or more attributes that, taken collectively, can uniquely identify a record.

Example: In a "Person" table, a super key could be the combination of "FirstName," "LastName," and "DateOfBirth."

Candidate Key:

Definition: A candidate key is a set of attributes that could potentially become a primary key.

For example: In the EMPLOYEE table, id is best suited for the primary key. The rest of the attributes, like SSN, Passport_Number, License_Number, etc., are considered a candidate key.