Composite Attribute in DBMS

A composite attribute in DBMS is an attribute that can be broken down into smaller, more basic attributes, called sub-attributes, which represent atomic values. These sub-attributes carry meaningful information individually, but together describe a larger concept.

Key Points:

  • Divisible: It can be split into smaller components.
  • Atomic Values: Each sub-attribute stores a single, indivisible piece of data.
  • Grouping of Related Data: The sub-attributes collectively describe a more complex characteristic.
  • Not Simple: Unlike simple attributes, which store only a single value, composite attributes store multiple related values.

For example:

  • Full Name can be divided into → First Name, Middle Name, Last Name
  • Address can be divided into → Street, City, State, Zip Code

Graphical Representation of Composite Attribute 

Represented by a large oval labeled with the composite attribute’s name.

  • The sub-attributes are shown as smaller ovals connected to the main oval with lines.
  • The sub-attributes are atomic (cannot be further divided).

Here is a diagram

Composite Attribute in DBMS - Graphical Representation

Can a composite attribute uniquely identify a tuple?

The simple answer is, not always.

  • A Composite Attribute is mainly for detailed representation, not for uniqueness. So there is no guarantee of uniqueness. For example, many people can share the same First Name + Last Name.

  • But in some special cases (like Employee {First Name, Last Name, Date of Birth}), the combination may be unique across all tuples. If that uniqueness holds, then it can be treated as a Candidate Key.

Example 01: Composite Attribute in DBMS

Given the Student table, where Full_Name and Address are composite attributes.

Student_ID Full_Name Address
101 Ali Raza (Street: Main Rd, City: Lahore, State: Punjab, Zip: 54000)
102 Sara Khan (Street: Canal Rd, City: Karachi, State: Sindh, Zip: 74000)
103 Ahmed Iqbal (Street: Mall Rd, City: Lahore, State: Punjab, Zip: 54000)

Let’s break the composite key into its smaller atomic attributes 

  • Full_Name = {First_Name, Last_Name}
  • Address = {Street, City, State, Zip_Code}
Student_ID First_Name Last_Name Street City State Zip_Code
101 Ali Raza Main Rd Lahore Punjab 54000
102 Sara Khan Canal Rd Karachi Sindh 74000
103 Ahmed Iqbal Mall Rd Lahore Punjab 54000

This makes data more atomic, searchable, and normalized.

Implementation of Composite Key Attribute in MYSQL

Composite attribute like Full_Name or Address is usually stored as a single column. To split it into atomic parts (sub-attributes), we can use string functions like SUBSTRING_INDEX() or SPLIT-like logic.

Here’s a full example using your Student table scenario. You can run this directly in an online MySQL editor.

Step 1: Create Table and Insert Data

CREATE TABLE Student (
Student_ID INT PRIMARY KEY,
Full_Name VARCHAR(100),
Address VARCHAR(200)
);

INSERT INTO Student (Student_ID, Full_Name, Address) VALUES
(101, 'Ali Raza', 'Street: Main Rd, City: Lahore, State: Punjab, Zip: 54000'),
(102, 'Sara Khan', 'Street: Canal Rd, City: Karachi, State: Sindh, Zip: 74000'),
(103, 'Ahmed Iqbal', 'Street: Mall Rd, City: Lahore, State: Punjab, Zip: 54000');

Step 2: Query to Split Full_Name into First_Name and Last_Name

SELECT
Student_ID,
SUBSTRING_INDEX(Full_Name, ' ', 1) AS First_Name,
SUBSTRING_INDEX(Full_Name, ' ', -1) AS Last_Name,
Address
FROM Student;

Explanation:

  • SUBSTRING_INDEX(Full_Name, ‘ ‘, 1) → takes everything before the first space → First_Name.

  • SUBSTRING_INDEX(Full_Name, ‘ ‘, -1) → takes everything after the last space → Last_Name.

Step 3: Query to Split Address into Atomic Attributes

SELECT
Student_ID,
SUBSTRING_INDEX(Full_Name, ' ', 1) AS First_Name,
SUBSTRING_INDEX(Full_Name, ' ', -1) AS Last_Name,
TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(Address, ',', 1), ':', -1)) AS Street,
TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(Address, ',', 2), ':', -1)) AS City,
TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(Address, ',', 3), ':', -1)) AS State,
TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(Address, ',', 4), ':', -1)) AS Zip_Code
FROM Student;

Explanation:

  • SUBSTRING_INDEX(Address, ‘,’, 1) → takes Street: Main Rd

  • SUBSTRING_INDEX(…, ‘:’, -1) → extracts value after : → Main Rd

  • TRIM() → removes extra spaces

  • Repeat the same logic for City, State, and Zip_Code

Step 4: Output

Student_ID First_Name Last_Name Street City State Zip_Code
101 Ali Raza Main Rd Lahore Punjab 54000
102 Sara Khan Canal Rd Karachi Sindh 74000
103 Ahmed Iqbal Mall Rd Lahore Punjab 54000

Now the composite attributes are broken into atomic, searchable columns, making the data normalized.

 Key Points about Composite Attributes

  • It can be subdivided into smaller attributes.
  • Do not hold atomic values (not indivisible).
  • Provide more detail and flexibility in data storage.
  • Useful for normalization and better database design.
  • Cannot be directly used as a Primary Key (but sub-attributes may be).

How Composite Attributes Work in DBMS

Composite attributes work by breaking down the original data into atomic elements that can be processed separately. These attributes are often represented using Entity-Relationship (ER) diagrams, where they are shown as attributes with multiple components.

In an ER diagram:

A composite attribute is typically denoted by an oval or circle with a connecting line to its sub-attributes.

Each sub-attribute within the composite attribute is treated as a simple attribute for data storage.

Difference Between Simple Attribute and Composite Attribute

Feature Simple Attribute Composite Attribute
Definition Cannot be divided further Can be divided into sub-attributes
Example Age, Salary Full Name (First, Last), Address (City, Zip)
Storage Stores atomic value Stores grouped values
Usage Used directly in queries Sub-attributes used for detailed queries

Conclusion

A Composite Attribute in DBMS is a powerful way to represent structured and detailed information in a database. By breaking attributes into smaller sub-attributes, databases become more organized, flexible, and meaningful. Common examples include Full Name and Address, which are widely used in real-world database applications.