One very important role of a database management system is to maintain
the data definitions for each table and columns in the database. Each piece of data
must be assigned a name, a data type (e.g. date, alphanumeric, numeric) and
a mandatory/optional status. Most DBMS packages will enforce these rules when
rows are added to the database. DBMS packages can also enforce domain rules.
For example, a domains for marital status, state codes or country codes
could be defined to ensure that only valid values are stored.
Most DBMS software will also enforce cardinality and optionality rules that
govern relationships between things of interest (i.e. tables).
Examples of such rules are as follows:
- Each customer may have zero, one or many orders.
- An order must be initiated by one and only one customer.
- An order must have one or many order items.
When rows are deleted from the database, the DBMS will ensure that
all dependent rows are also deleted, leaving the database in a stable state.
For example, if an order is deleted, the DBMS would ensure that all related
order items are also deleted. Enforcing referential integrity rules is
an important role of database management systems.