rental
Documentation | Sakila |
Name | rental |
Module | Business |
The rental table contains one row for each rental of each inventory item with information about who rented what item, when it was rented, and when it was returned.
The rental table refers to the inventory, customer, and staff tables and is referred to by the payment table.
Columns
Key | Name | Data type | Null | Attributes | References | Description | ||
---|---|---|---|---|---|---|---|---|
1 | rental_id | int(10, 0) | Identity / Auto increment column | A surrogate primary key that uniquely identifies the rental. | ||||
A surrogate primary key that uniquely identifies the rental. Identity / Auto increment column |
||||||||
2 | rental_date | datetime | he date and time that the item was rented. | |||||
he date and time that the item was rented. |
||||||||
3 | inventory_id | unsigned mediumint(7, 0) | inventory | The item being rented. | ||||
The item being rented. References: inventory |
||||||||
4 | customer_id | unsigned smallint(5, 0) | customer | The customer renting the item. | ||||
The customer renting the item. References: customer |
||||||||
5 | return_date | datetime | The date and time the item was returned. | |||||
The date and time the item was returned. |
||||||||
6 | staff_id | unsigned tinyint(3, 0) | staff | The staff member who processed the rental. | ||||
The staff member who processed the rental. References: staff |
||||||||
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 | |
---|---|---|---|---|
rental | customer | rental.customer_id = customer.customer_id | fk_rental_customer Foreign key constraint referencing customer.customer_id |
|
rental.customer_id = customer.customer_id Name: fk_rental_customerForeign key constraint referencing customer.customer_id |
||||
rental | inventory | rental.inventory_id = inventory.inventory_id | fk_rental_inventory Foreign key constraint referencing inventory.inventory_id |
|
rental.inventory_id = inventory.inventory_id Name: fk_rental_inventoryForeign key constraint referencing inventory.inventory_id |
||||
rental | staff | rental.staff_id = staff.staff_id | fk_rental_staff Foreign key constraint referencing staff.staff_id |
|
rental.staff_id = staff.staff_id Name: fk_rental_staffForeign key constraint referencing staff.staff_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 |
Unique keys
Key name | Columns | Description | |
---|---|---|---|
PRIMARY | rental_id | Primary key. | |
Primary key. | |||
rental_date | rental_date, inventory_id, customer_id | Unique index. | |
Unique index. |
Triggers
Key name | When | Description | |
---|---|---|---|
rental_date | Before Insert | The rental_date trigger sets the rental_date column of the rental table to the current time and date as rows are inserted. | |
The rental_date trigger sets the rental_date column of the rental table to the current time and date as rows are inserted. |
Used by
Name |
---|
rental
|
Exported: 2018-10-12 17:43, Last imported: 2018-08-06 10:44