Informatics Practices · Ch 1 — Querying and SQL Functions
Union (U)
Union (U)
Union (∪)
The Union operation combines the selected rows from two tables into a single result. If a row appears in both tables, it is shown only once in the output — duplicates are automatically removed. This is exactly how the union of two sets works in mathematics: every element that belongs to either set appears exactly once in the union. Figure 1.3 shows this as a Venn diagram — the union is the entire shaded region covered by either circle.
Consider two relations: DANCE (students who have registered for dance, Table 1.10) and MUSIC (students who have registered for music, Table 1.11). Their structures are identical — each has columns SNo, Name, and Class.
If we want a list of all students participating in either dance or music (or both), we apply the Union operation on the two relations. The result — shown in Table 1.12 — has seven distinct rows: all four from DANCE plus the three from MUSIC that were not already present. Mahira (SNo 2, Class 6A) and Sanjay (SNo 4, Class 7A) appear in both source tables, but in the union they appear only once each. …
Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your textbook's own diagram.
The figure is a Venn diagram with two overlapping circles, no surrounding rectangle. The left circle is labelled Music, the right circle is labelled Dance — matching this chapter's own MUSIC and DANCE example tables. Both circles are entirely shaded solid blue, covering the region belonging only to Music, the region belonging only to Dance, and the overlapping region common to both. …
| SNo | Name | Class |
|---|---|---|
| 1 | Aastha | 7A |
| 2 | Mahira | 6A |
| 3 | Mohit | 7B |
| SNo | Name | Class |
|---|---|---|
| 1 | Mehak | 8A |
| 2 | Mahira | 6A |
| 3 | Lavanya | 7A |
| SNo | Name | Class |
|---|---|---|
| 1 | Aastha | 7A |
| 2 | Mahira | 6A |
| 3 | Mohit | 7B |
| 4 | Sanjay | 7A |
| 1 | Mehak | 8A |