4.3: Structured Query Language
- Page ID
Once you have a database designed and loaded with data, how will you do something useful with it? The primary way to work with a relational database is to use Structured Query Language, SQL (pronounced “sequel,” or stated as S-Q-L). Almost all applications that work with databases (such as database management systems, discussed below) use SQL to analyze and manipulate relational data. As its name implies, SQL is a language that can be used to work with a relational database or for streaming processing in a relational data stream management system. From a simple request for data to a complex update operation, SQL is a mainstay of programmers and database administrators. To give you a taste of what SQL might look like, here are a couple of examples using our Student Clubs database.
• The following query will retrieve a list of the first and last names of the club presidents:
SELECT "First Name," "Last Name" FROM "Students" WHERE "Students.ID" =
• The following query will create a list of the number of students in each club, listing the club name and then the number of members:
SELECT "Clubs.Club Name", COUNT("Memberships.Student ID") FROM "Clubs"
An in-depth description of how SQL works is beyond this introductory text's scope. Still, these examples should give you an idea of the power of using SQL to manipulate relational data. Many database packages, such as Microsoft Access, allow you to visually create the query you want to construct and then generate the SQL query for you.
Rows and Columns in a Table
In a relational database, all the tables are related by one or more fields so that it is possible to connect all the tables in the database through the field(s) they have in common. For each table, one of the fields is identified as a primary key. This key is the unique identifier for each record in the table. To help you understand these terms further, let’s walk through the process of designing the following database.