This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Creating a table with foreign key references. | |
create table user_order( | |
id int not null PRIMARY key AUTO_INCREMENT, | |
user_id int not null, | |
shipping_address_id int not null, | |
order_date timestamp DEFAULT CURRENT_TIMESTAMP, | |
total_quantity int not null, | |
total_price int not null, | |
FOREIGN KEY (user_id) REFERENCES user(id), | |
FOREIGN KEY (shipping_address_id) REFERENCES shipping_address(id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- One to one relation between user_order and shipping_address table. | |
create table user_order ADD UNIQUE index("id", "shipping_address_id"); |
OlderNewer