The city table

This article introduces the structure of the city table in the Sakila database.

The city table contains a list of cities.

The city table refers to the the country table using a foreign key.

The address table refers to the city table using a foreign key.

Table Structure

The structure of the city table is as follows:

+-------------+-------------------+------+-----+-------------------+-----------------------------------------------+
| Field       | Type              | Null | Key | Default           | Extra                                         |
+-------------+-------------------+------+-----+-------------------+-----------------------------------------------+
| city_id     | smallint unsigned | NO   | PRI | NULL              | auto_increment                                |
| city        | varchar(50)       | NO   |     | NULL              |                                               |
| country_id  | smallint unsigned | NO   | MUL | NULL              |                                               |
| last_update | timestamp         | NO   |     | CURRENT_TIMESTAMP | DEFAULT_GENERATED on update CURRENT_TIMESTAMP |
+-------------+-------------------+------+-----+-------------------+-----------------------------------------------+

Table Columns

The following table explains all columns in the city table.

Column Description
city_id The surrogate primary key used to uniquely identify each city in the table.
city City name.
country_id A foreign key that identifies the country to which the city belongs.
last_update The time when the row was created or last updated.