All modern database programs are based on the relational database model, which organizes logically related data into tables. These tables, which are known as relations, are subdivided into rows and columns. Each column, or attribute, of a relation keeps up with a particular kind of data. Each row, or tuple, of a relation holds all of the data about a particular entity or event.
contains the “Faculty” relation from a hypothetical university database. This relation (table) has six attributes (columns): “Fname” which stands for the faculty member’s name, “Dept” the department in which the faculty member serves, “Office” the building code and room number where the faculty member’s office is located, “Phone” the faculty member’s phone number, “SSN” the faculty member’s social security number, and “Salary” the faculty member’s nine-month academic-year salary. In addition to these six attributes, the “Faculty” relation contains seven tuples (rows).
Each attribute of holds a particular type of information, like phone numbers or salaries. Each tuple contains all of the different kinds of information known about a particular individual.
presents another relation from our university database. This relation is the “Students” relation, which keeps up with all of the various kinds of information maintained about students. The “Students” relation consists of eight attributes: “Sname”, “Age”, “Major”, “ID”, “Sex”, “Address”, “City”, and “State”; and twenty tuples, one for each student attending this (quite small) university.
the “Students” relation – part of a university database
By now you may have noticed the similarities between files with their records and fields, and relations with their tuples and attributes. In fact, the tuples of a relation are quite similar to the records of a file, and attributes are analogous fields. However, you should not assume that every relation in a database will actually be stored as a separate file on a disk drive. In fact, you don’t even need to worry about files and records when using a relational database, since the application will handle all of those details for you. Instead, try to think in terms of tables (relations) with their rows (tuples) and columns (attributes).
Now that we have some idea of how data is organized in the relational model, the obvious question is: “How can relational databases be used to answer questions about the data contained in the relations?”.
The relational model provides three query operators:
Select
Project
Join
A query may be thought of as a question posed to the database. Query operators act on existing relations and always produce new relations as output.