The payment table
This article introduces the structure of the payment table in the Sakila database.
The payment table records every payment made by the customer, includes information such as the amount and rent paid.
The payment table refers to the customer using a foreign key.
The payment table refers to the rental using a foreign key.
The payment table refers to the staff using a foreign key.
Table Structure
The structure of the payment table is as follows:
+--------------+-------------------+------+-----+-------------------+-----------------------------------------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------------+------+-----+-------------------+-----------------------------------------------+
| payment_id | smallint unsigned | NO | PRI | NULL | auto_increment |
| customer_id | smallint unsigned | NO | MUL | NULL | |
| staff_id | tinyint unsigned | NO | MUL | NULL | |
| rental_id | int | YES | MUL | NULL | |
| amount | decimal(5,2) | NO | | NULL | |
| payment_date | datetime | NO | | NULL | |
| last_update | timestamp | YES | | CURRENT_TIMESTAMP | DEFAULT_GENERATED on update CURRENT_TIMESTAMP |
+--------------+-------------------+------+-----+-------------------+-----------------------------------------------+
Table Columns
The following table explains all columns in the payment table.
| Column | Description |
|---|---|
payment_id |
The proxy key used to uniquely identify each payment. |
customer_id |
The customer whose balance is being applied to. There is a foreign key reference the customer table using this field. |
staff_id |
The employee who processes the payment. There is a foreign key reference the staff table using this field. |
rental_id |
The rent applicable to the payment.This is optional because some payments are for unpaid expenses and may not be directly related to rent. |
amount |
The amount paid. |
payment_date |
The date the payment was processed. |
last_update |
The time when the row was created or last updated. |