Table payment
This table records each payment made by a customer, with information such as the amount and the rental being paid for (when applicable). The table refers to the customer, rental, and staff table.
Schema
This table belongs to schema sakila.
Columns
This table contains 7 columns.
payment_id
-
smallint
·NOT NULL
A surrogate primary key used to uniquely identify each payment.
customer_id
-
smallint
·NOT NULL
The customer whose balance the payment is being applied to. This is a foreign key reference to the customer table.
staff_id
-
smallint
·NOT NULL
The staff member who processed the payment. This is a foreign key reference to the staff table.
rental_id
-
The rental that the payment is being applied to. This is optional because some payments are for outstanding fees and may not be directly related to a rental.
amount
-
numeric(5,2)
·NOT NULL
The amount of the payment.
payment_date
-
timestamp(0) without time zone
·NOT NULL
The date the payment was processed.
last_update
-
timestamp(0) without time zone
·CURRENT_TIMESTAMP
When the row was created or most recently updated.
Primary key
This table has a primary key.
payment
-
payment_id
Foreign keys
This table has one foreign key.
fk_payment_customer
-
customer_id
»sakila.customer (customer_id)
·ON UPDATE CASCADE
·ON DELETE RESTRICT
fk_payment_rental
-
rental_id
»sakila.rental (rental_id)
·ON UPDATE CASCADE
·ON DELETE SET NULL
fk_payment_staff
-
staff_id
»sakila.staff (staff_id)
·ON UPDATE CASCADE
·ON DELETE RESTRICT
Indices
This table has 3 indices.
payment_pkey
-
payment_id
idx_payment_fk_customer_id
-
customer_id
idx_payment_fk_staff_id
-
staff_id