Полезная информация

next up previous contents index
Next: Creating Tables Up: Five Basic SQL Commands Previous: Five Basic SQL Commands

Relational Databases

As I mentioned in section [*], the purpose of a database is rapid data storage and retrieval. Today, most database systems are relational databases. While the term relational database has a mathematical foundation, practically it means that all data stored in the database is arranged in a uniform structure.

In figure [*], you see the database server with access to three databases, test, demo, and finance.

Figure: Databases


You could issue the command psql finance and be connected to the finance database. You have already dealt with this in chapter [*]. Using psql, you chose to connect to database test with the command psql test. To see a list of databases available at your site, type psql -l. The first column lists the database names. However, you may not have permission to connect to them.

You may ask, ``What are those black rectangles in the databases?'' Good question. Those are tables. Tables are the foundation of a relational database management system (RDBMS). As I mentioned earlier, databases store data. Those tables are where all the data is stored in a database. Each table has a name defined by the person who created it.

Let's look at a single table called friends in table [*].

Table: Table friends
FirstName LastName City State Age
Mike Nichols Tampa FL 19
Cindy Anderson Denver CO 23
Sam Jackson Allentown PA 22

You can easily see how tables are used to store data. Each friend is listed as a separate row in the table. The table records five pieces of information about each friend, firstname, lastname, city, state, and age.

Each friend is on a separate row. Each column contains the same type of information. This is the type of structure that makes relational databases successful. Relational databases allow you to select certain rows of data, certain columns of data, or certain cells. You could select the entire row for Mike, the entire column for City, or a specific cell like Denver. There are synonyms for the terms table, row, and column. Table is more properly referred to as a relation or class, row as record or tuple, and column as field or attribute.

next up previous contents index
Next: Creating Tables Up: Five Basic SQL Commands Previous: Five Basic SQL Commands
Bruce Momjian