12.5. SQL: Choosing Columns, Rows, and Order

Recall that relational algebra includes the following eight table operations: union, intersection, difference, Cartesian product, selection, projection, join, and division. All of these operations (as well as others) can be expressed using SQL’s powerful select statement. This section discusses how SQL is used to perform relational projection and selection, as well as bag projection and row ordering.

First let’s see how to choose columns. Consider a small UoD where people are identified by their firstname. Table 12.5 provides sample data for the table scheme: Person (firstname. gender, starsign, birthyr).

Table 12.5. A relational table storing personal details.
     
Person:firstnamegenderstarsign

Get Information Modeling and Relational Databases, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.