Created
September 23, 2021 01:49
-
-
Save nix1947/dc68cd741c3bb4cb6068220bf0c61c31 to your computer and use it in GitHub Desktop.
Creating a foreign key table in mysql with references.
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) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment