payment
| Documentation | Sakila |
| Name | payment |
| Module | Business |
The payment table records each payment made by a customer, with information such as the amount and the rental being paid for (when applicable).
The payment table refers to the customer, rental, and staff tables.
Columns
| Key | Name | Data type | Null | Attributes | References | Description | ||
|---|---|---|---|---|---|---|---|---|
| 1 | payment_id | unsigned smallint(5, 0) | Identity / Auto increment column | A surrogate primary key used to uniquely identify each payment. | ||||
| A surrogate primary key used to uniquely identify each payment. Identity / Auto increment column |
||||||||
| 2 | customer_id | unsigned smallint(5, 0) | customer | The customer whose balance the payment is being applied to. This is a foreign key reference to the customer table. | ||||
| The customer whose balance the payment is being applied to. This is a foreign key reference to the customer table. References: customer |
||||||||
| 3 | staff_id | unsigned tinyint(3, 0) | staff | The staff member who processed the payment. This is a foreign key reference to the staff table. | ||||
| The staff member who processed the payment. This is a foreign key reference to the staff table. References: staff |
||||||||
| 4 | rental_id | int(10, 0) | rental | 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. | ||||
| 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. References: rental |
||||||||
| 5 | amount | decimal(5, 2) | The amount of the payment. | |||||
| The amount of the payment. |
||||||||
| 6 | payment_date | datetime | The date the payment was processed. | |||||
| The date the payment was processed. |
||||||||
| 7 | last_update | timestamp | Default: CURRENT_TIMESTAMP | The time that the row was created or most recently updated. | ||||
| The time that the row was created or most recently updated. Default: CURRENT_TIMESTAMP |
||||||||
Relations
| Foreign table | Primary table | Join | Title / Name / Description | |
|---|---|---|---|---|
| payment | customer | payment.customer_id = customer.customer_id | fk_payment_customer Foreign key constraint referencing customer.customer_id |
|
|
payment.customer_id = customer.customer_id Name: fk_payment_customerForeign key constraint referencing customer.customer_id |
||||
| payment | rental | payment.rental_id = rental.rental_id | fk_payment_rental Foreign key constraint referencing rental.rental_id |
|
|
payment.rental_id = rental.rental_id Name: fk_payment_rentalForeign key constraint referencing rental.rental_id |
||||
| payment | staff | payment.staff_id = staff.staff_id | fk_payment_staff Foreign key constraint referencing staff.staff_id |
|
|
payment.staff_id = staff.staff_id Name: fk_payment_staffForeign key constraint referencing staff.staff_id |
||||
Unique keys
| Key name | Columns | Description | |
|---|---|---|---|
| PRIMARY | payment_id | Primary key. | |
| Primary key. | |||
Triggers
| Key name | When | Description | |
|---|---|---|---|
| payment_date | Before Insert | The payment_date trigger sets the payment_date column of the payment table to the current time and date as rows are inserted. | |
| The payment_date trigger sets the payment_date column of the payment table to the current time and date as rows are inserted. | |||
Exported: 2018-10-12 17:43, Last imported: 2018-08-06 10:44
