How do I use a joint primary key as a foreign key? I have a table whose primary key is the Union primary key. this Union primary key is the foreign key in another table. what should I do? & Nbsp; for example: CREATETABLEIFNOTEXISTScustomers (& nbsp; firstnamevarchar (25) notnull, & nbsp; how to use the joint primary key as the foreign key?
I have a table whose primary key is the Union primary key. this Union primary key is the foreign key in another table. what should I do?
For example:
Create table if not exists mers (
Firstname varchar (25) not null,
Lastname varchar (25) not null,
Certificatetype varchar (25) not null,
Certificatenumber varchar (25) not null,
Gender varchar (6) not null,
Constraint uc_customerID primary key (certificatetype, certificatenumber)
);
Create table if not exists cab_status (
ID int not null AUTO_INCREMENT primary key,
Roomname varchar (10) not null,
Certificatetype varchar (25) not null,
Certificatenumber varchar (25) not null,
Foreign key () references customer ()
)";
I want to use certificatetype and certificatenumber as the primary key of MERS and as the foreign key of cab_status. what should I do in red?
Because the names of people may be repeated, I like to use the document type and document number as the primary key.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.