The first step in creating a database is to create one or more table to hold your data.
A table has a columns(or fields) and rows. A single row of data
is called a record. From a table, you might select a subset of rows or columns
but the result always appears on screen or in print as another table.
Each table must have an element that uniquely identifies each row of the table. This element,
called the primary key, can be stored in one or in a combination of columns.
In our example primary key is Id_number. A key column can be stored in other tables.
When this is done, the column is called a foreign key.
CREATE TABLE Worker (
Id_number CHAR(5) PRIMARY KEY,
Name CHAR(5),
Tel NUMBER(10),
Age NUMBER,
Salary NUMBER(3,2),
Department CHAR(10) REFERENCES
DEPARTMENT(Skills),
Date_of_birth DATE
);
In our example primary key is Id_number
Primary key column cannot contain null(worker
information is not useful without Id_number).
The foreign key is Department.
Department column refers to values for the
Department column in the Skills table.
|
|