The rental table
This article introduces the structure of the rental
table in the Sakila database.
The rental
table contains a row for each rental of each inventory item, which contains information about who rented what, when it rented it, and when it was returned.
The rental
table defines foreign keys that refers to the inventory
, customer
and staff
tables.
The payment
table refers to the rental
using a foreign key.
Table Structure
The structure of the rental
table is as follows:
+--------------+--------------------+------+-----+-------------------+-----------------------------------------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------------+------+-----+-------------------+-----------------------------------------------+
| rental_id | int | NO | PRI | NULL | auto_increment |
| rental_date | datetime | NO | MUL | NULL | |
| inventory_id | mediumint unsigned | NO | MUL | NULL | |
| customer_id | smallint unsigned | NO | MUL | NULL | |
| return_date | datetime | YES | | NULL | |
| staff_id | tinyint 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 rental
table.
Column | Description |
---|---|
rental_id |
The surrogate primary key that uniquely identifies the lease. |
rental_date |
The date and time the item was rented. |
inventory_id |
Items being rented. |
customer_id |
Customers who rent items. |
return_date |
The date and time the item was returned. |
staff_id |
The staff handling the lease. |
last_update |
The time when the row was created or last updated. |