mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-02 10:36:28 +00:00
19 lines
1.0 KiB
SQL
19 lines
1.0 KiB
SQL
-- Modified so the customer_id is nullable.
|
|
CREATE TABLE `rental` (
|
|
`rental_id` int(11) NOT NULL auto_increment,
|
|
`rental_date` datetime NOT NULL,
|
|
`inventory_id` mediumint(8) unsigned NOT NULL,
|
|
`customer_id` smallint(5) unsigned default NULL,
|
|
`return_date` datetime default NULL,
|
|
`staff_id` tinyint(3) unsigned NOT NULL,
|
|
`last_update` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`rental_id`),
|
|
UNIQUE KEY `rental_date` (`rental_date`,`inventory_id`,`customer_id`),
|
|
KEY `idx_fk_inventory_id` (`inventory_id`),
|
|
KEY `idx_fk_customer_id` (`customer_id`),
|
|
KEY `idx_fk_staff_id` (`staff_id`),
|
|
CONSTRAINT `fk_rental_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE,
|
|
CONSTRAINT `fk_rental_inventory` FOREIGN KEY (`inventory_id`) REFERENCES `inventory` (`inventory_id`) ON UPDATE CASCADE,
|
|
CONSTRAINT `fk_rental_staff` FOREIGN KEY (`staff_id`) REFERENCES `staff` (`staff_id`) ON UPDATE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|