RDBMS DefinitionRelational databases store data in tables (relations) that are two dimensional. The tables have rows (records or objects) and columns (fields or attributes). Data items at an intersection of a row and a column are called a cell and consist of attribute values. Data stored is simple data such as integers, real numbers or string values. Multiple values may not be stored in one cell. Relational database tables are "normalized" so data is not repeated more often than necessary. All table columns depend on a primary key (a unique value in the column) to identify the column. Once the specific column is identified, data from one or more rows associated with that column may be obtained or changed. Relational databases are sets of tables. One table file is not a relational database. A relational database server is not the same as a relational database. A relational database can be a file with sets of tables. The relational database server includes the ability to service requestesto get or change data from remote clients. Relational database servers use Structured Query Language (SQL), as a data manipulation language to interface between itself and the clients. SQL is the standard for getting and storing data in an RDBMS. For information about SQL, see the "Beginner's SQL Guide". Relational database servers provide:
Primary KeysIn relational databases, the data is not arranged in any particular order in tables. The data in tables requires keys for identification of rows. Each table has rows and columns. Sets of values in a row may describe a particular item such as customers. Consider the following table:
|
Columns include Customer ID, Name, Street Address, City and so forth. Each column has a different set of information about all customers such as their phone number. This information could be considered customer characteristics or attributes. Each row has all information about one particular customer. Each row must have a unique means of identification. We could have used the customer name to identify the customer, but it is possible that more than one customer may have the same name. Therefore we are using unique customer identifiers. The Customer ID is the key used to identify individual customers. The column to be used as the key must be identified to the relational database. This is called the primary key.
Let's say we're running a store with the customers listed above. The first table below lists items for sale. The second table lists orders that have been placed in the store, and the third table lists items ordered for an individual order. If we want to print out what items customer 234902 ordered we do the following:
| Item ID | Description | Price |
|---|---|---|
| 000234567 | Small Flower Pot | 2.36 |
| 000018901 | Potting Soil | 5.97 |
| 001034654 | Geranium Seed | 1.50 |
| Order ID | Customer ID | Subtotal | Tax | Total |
|---|---|---|---|---|
| 190389575 | 234902 | 16.16 | 0.82 | 16.98 |
| 109748230 | 187462 | 2.37 | 0.12 | 2.49 |
| 208949023 | 059385 | 104.23 | 5.22 | 109.45 |
| 103792034 | 187462 | 40.00 | 2.00 | 42.00 |
| 123048938 | 134056 | 10.00 | 0.50 | 10.50 |
| Item ID | Quantity |
|---|---|
| 000234567 | 2 |
| 000018901 | 2 |
| 001034654 | 1 |
Therefore foreign keys are used to access data in related tables.