Information Technology Topic

Database Terminology

  1. Read notes
  2. Flashcards
  3. Quiz
  4. Confident

Study focus - 3 things

  1. A table (also called a relation) holds the information about one entity, such as one kind of stock item
  2. One row is a record, also called a tuple, and one column is a field, also called an attribute
  3. File words and database words name the same parts, and you count records (rows of data) and fields (columns), never the heading row

Visual notes

A labelled database table
A table named Stock with the field names ItemCode, ItemName, Price, QtyInStock across the top and 6 records beneath them: A01, Rice (2 kg), 480, 24; A02, Flour (1 kg), 310, 40; A03, Cooking oil, 650, 18; A04, Sugar (1 kg), 290, 35; A05, Tinned mackerel, 410, 22; A06, Water (1.5 L), 220, 60. Six numbered parts are marked. Part 1 is the table name Stock, part 2 is the heading row of field names, part 3 is the whole record A03, Cooking oil, 650, 18 outlined in teal, part 4 is the Price field, an entire column outlined with dashes, part 5 is the single field value 35 (the quantity of Sugar (1 kg)) in a thick box, and part 6 is the ItemCode field, shaded as the key field. A legend below the table names each part.

1 table name, 2 field names, 3 record, 4 field (the Price column), 5 field value, 6 key field.

Section 1Table, relation and entity

A table is a grid of rows and columns that holds information about one kind of thing. In database language a table is also called a relation. The two words mean the same. The kind of thing a table is about is called the entity. A shop's Stock table is about the entity stock item. A Student table is about the entity student. Each row of the table describes one example of the entity, and each column describes one detail of it. Here's the trick: name the table after the entity it describes, and you will always know what a row stands for.

Section 2Rows, records and tuples

One row of a table holds all the details about one item. It has three names: a row, a record or a tuple. In the figure, the row A03, Cooking oil, 650, 18 is one record. It tells you everything the table knows about one item. A tuple is the mathematical name for the same thing: a set of values in a fixed order. Records in a table all have the same pattern of values. Easy to mix up: the word 'record' is also used for a row in a plain file, but the meaning is the same, one complete set of details.

Section 3Columns, fields and attributes

One column of a table holds one kind of detail for every record. It has three names: a column, a field or an attribute. In the Stock table the fields are ItemCode, ItemName, Price and QtyInStock. The Price field is the whole column of six prices. Each field has a name, and every record has a value for it. An attribute is a named detail of the entity, such as the price of a stock item. Watch out: a field is the whole column. A single entry such as 650 is not a field, it is a value stored in the Price field.

Section 4File words and database words

Older paper and computer files talk about records and fields. Databases use records and fields too, but also the terms row, tuple, column and attribute. They are different names for the same parts. A row = a record = a tuple. A column = a field = an attribute. A table = a relation. Use whichever word the question uses. If it says tuple, think row. If it says attribute, think column. Here's the trick: the word 'tuple' belongs with rows, and 'attribute' belongs with columns. Say them in pairs and they stick.

Section 5Field values and the key field

The single entry where a record and a field meet is a field value. In the Stock table, 'Tinned mackerel' is the value of the ItemName field in record A05. One field is usually chosen to name each record. Here it is ItemCode, because every item has a different code. A field used this way is called a key field, and the next topic covers keys in detail. A key field never repeats. If two items could share a code, the code could not tell them apart.

Section 6Counting a table

The Stock table in a Mandeville shop has the fields ItemCode, ItemName, Price, QtyInStock and holds: A01, Rice (2 kg), 480, 24; A02, Flour (1 kg), 310, 40; A03, Cooking oil, 650, 18; A04, Sugar (1 kg), 290, 35; A05, Tinned mackerel, 410, 22; A06, Water (1.5 L), 220, 60. Count the records by counting the rows of data: 6 records. Count the fields by counting the column headings: 4 fields. The heading row is not a record. The number of field values is the number of records times the number of fields: 6 times 4 = 24 values. Add a new record and the count grows by one record, and by one value for each field. A seventh item gives 7 records and 28 values. Here's the trick: records go down the page, fields go across it.

Examples

The Stock table in a Mandeville shop has the fields ItemCode, ItemName, Price, QtyInStock and holds: A01, Rice (2 kg), 480, 24; A02, Flour (1 kg), 310, 40; A03, Cooking oil, 650, 18; A04, Sugar (1 kg), 290, 35; A05, Tinned mackerel, 410, 22; A06, Water (1.5 L), 220, 60. (a) Name the entity the Stock table describes. (b) How many records does the table have? (c) How many fields does it have? (d) Give three names for A03, Cooking oil, 650, 18. (e) Give three names for the Price column.

(a) The entity is a stock item. Each row describes one item. (b) Count the rows of data: A01 to A06, so 6 records. The heading row is not counted. (c) Count the column headings: ItemCode, ItemName, Price and QtyInStock, so 4 fields. (d) It is one row, so it is a row, a record or a tuple. (e) It is one column, so it is a column, a field or an attribute.

The Stock table in a Mandeville shop has the fields ItemCode, ItemName, Price, QtyInStock and holds: A01, Rice (2 kg), 480, 24; A02, Flour (1 kg), 310, 40; A03, Cooking oil, 650, 18; A04, Sugar (1 kg), 290, 35; A05, Tinned mackerel, 410, 22; A06, Water (1.5 L), 220, 60. (a) How many field values does the table hold? (b) How many records have more than 25 units in QtyInStock? (c) How many units are in stock altogether? (d) Which ItemCode belongs to the record with the lowest Price? (e) A new record, A07, Pepper sauce, 380, 15, is added. How many records and how many field values are there now?

(a) 6 records times 4 fields = 24 field values. (b) The quantities are 24, 40, 18, 35, 22 and 60. Those over 25 are 40, 35 and 60, so 3 records (A02, A04 and A06). (c) Add the QtyInStock field: 24 + 40 + 18 + 35 + 22 + 60 = 199 units. (d) The lowest price is 220, in record A06, so the ItemCode is A06. (e) There are now 7 records and 7 times 4 = 28 field values.

Now let's water it

Session runs notes to flashcards to quiz back-to-back.

Where this comes from