Dbms
Dbms
what is dbms?
Database Management Systems (DBMS) are software systems used to store, retrieve,
and run queries on data.
A DBMS serves as an interface between an end-user and a database, allowing users
to create, read, update, and delete data in the database.
Keys
A key is one or more columns that are identified as such in the creation of a table
or index, or in the definition of referential integrity.
Primary key
A table can only have one primary key because it defines the entity.
Creating an index automatically creates the index space, the data set that contains
the index.
There are two requirements for a primary key:
It must have a value, that is, it cannot be null.
It must be unique, that is, it must have a unique index defined on it.
Unique key
We already know that a primary key must be unique, but it is possible to have more
than one unique key in a table.
In our EMP table example, the employee number is defined as the primary key and is
therefore unique.
If we also had a social security value in our table, hopefully that value would be
unique.
To guarantee this, you could create a unique index on the social security column.
Foreign key
A foreign key is a key that is specified in a referential integrity constraint to
make its
existence dependent on a primary or unique key (parent key) in another table.
The example given is that of an employee's work department number relating to the
primary key defined on the department number in the DEPT table. This constraint is
part of the definition of the table.