Set Difference(-)

Set A-B

A binary operation that gives tuples in one relation but not present in another relation. In simple terms, it returns all the rows from the first relation, which is not present in the second one. For Example: Perform Set Difference Operation in relation R and Relation S.

Relation R

Relation S

Relation R-S, After Performing Set Difference operation

Relation R-S

Here all the Alphabet which are in R but not in S are shown. Note Preference will be given to the first relation attributes in this case ‘Alphabet’ of relation R.

Set Difference Operator in Relational Algebra

Relational Algebra is used to play with the data stored in relational databases. Relational Algebra has many operations to play with tables. One of the fundamental operations is set difference. This article will discuss Set Difference, its condition, and its examples.

Similar Reads

Key Terms Used in Set Difference Operator

Relation- In Relational Algebra ‘Table’ is called a Relation. Tuple- In Relational Algebra ‘Row’ is called as Tuple. Attribute- In Relational Algebra ‘Column’ is called an Attribute....

Set Difference(-)

Set A-B...

Condition for Set Difference

1. Both relations must have the same number of attributes. 2. The data type of their corresponding attributes must be the same....

Examples

Question 1: Consider the below tables Employee and Student. Perform Set Difference operation as (Employee-Student)....

Conclusion

The Set Difference operator is a powerful tool when you want to know the uncommon element present in the table. Having a good understanding and the application of this operator can help in filtering the records and values from the given Relations....