A tuple in the context of a relational database refers to a single row or record in a relation (or table). A tuple is an ordered set of attribute values that represents a unique data entry for an entity or relationship described by the relation.
In simpler terms, a tuple corresponds to one complete entry in a table, and each attribute within the tuple contains a value for a particular property of the entity represented by the relation.
Tuple as a Row:
Ordered Set of Values:
Uniqueness of Tuples:
Tuple in a Table:
Consider a table called Students which stores information about university students:
| StudentID | Name | Age | Major |
|---|---|---|---|
| 101 | John Doe | 20 | Computer Science |
| 102 | Jane Smith | 21 | Mathematics |
| 103 | Alice Lee | 19 | Biology |
In this example:
For example, the first tuple is:
('101', 'John Doe', 20, 'Computer Science')StudentID of 101, is 20 years old, and is majoring in Computer Science.The second tuple is:
('102', 'Jane Smith', 21, 'Mathematics')Each tuple represents one complete record in the database and contains data for each attribute of the Students relation.
Atomicity:
PhoneNumber attribute of a student is required, it must store a single phone number, not multiple numbers.Fixed Length:
Uniqueness:
No Ordering of Tuples:
Let’s look at an example to understand how tuples relate to attributes and represent records in a database.
Employees Table:| EmployeeID | Name | Age | Department | Salary |
|---|---|---|---|---|
| 1 | John Doe | 30 | HR | 55000 |
| 2 | Jane Smith | 25 | IT | 65000 |
| 3 | Alice Johnson | 28 | Marketing | 60000 |
Here:
('1', 'John Doe', 30, 'HR', 55000)('2', 'Jane Smith', 25, 'IT', 65000)('3', 'Alice Johnson', 28, 'Marketing', 60000)Each tuple contains values for the attributes EmployeeID, Name, Age, Department, and Salary.
Select: Tuples are selected when we query the database.
IT department would return the tuple ('2', 'Jane Smith', 25, 'IT', 65000).Insert: When new data is added to the table, a new tuple is inserted into the relation.
EmployeeID = 4, Name = Bob Brown, Age = 35, Department = Finance, and Salary = 70000 would create a new tuple: ('4', 'Bob Brown', 35, 'Finance', 70000).Delete: A tuple can be deleted from the relation based on specific conditions.
EmployeeID = 3 would remove ('3', 'Alice Johnson', 28, 'Marketing', 60000) from the table.Update: A specific tuple can be updated (its attribute values changed) based on certain conditions.
Jane Smith would change the value of the Salary attribute in the tuple ('2', 'Jane Smith', 25, 'IT', 65000).Entity Integrity:
EmployeeID or StudentID. This prevents duplicate records.Referential Integrity:
Order tuple might have a CustomerID attribute that refers to the CustomerID of a customer in the Customers table, ensuring the validity of relationships between tuples in different tables.A tuple in a relational database is a row or record in a table, where each value corresponds to a specific attribute (column) of that relation. Tuples represent the data entries of entities or relationships in the database and are fundamental in querying, inserting, updating, and deleting records. In essence, a tuple is a collection of related data points that together describe a single entity instance in the context of a database.
Open this section to load past papers