' datetime default NULL,
' updated_time ' datetime default NULL,
' Level ' int (one) not null default ' 0 ',
' description ' varchar default NULL,
PRIMARY key (' id '),
UNIQUE key ' Id_index_1 ' (' id ') USING HASH
Next we need to correlate product.sid to sealer.id for the primary foreign Key Associat
the score table is the foreign key of the students ' table.The course number in the results table is that the foreign key of the curriculum defines the primary key and foreign key prim
This article mainly introduces the specific definition and usefulness of super-key, candidate key, primary key, main attribute, foreign key in MySQL database. You can also refer to the topic.alibabacloud.com MySQL video tutorial and
MySQL manual。
First look at the definitio
. Defining primary and foreign keys is primarily to maintain the integrity of the relational database, summarizing: A primary key is a unique identifier that determines a record, for example, a record that includes a social security number, name, and age. The ID number is the only person who can identify you, others may have duplicates, so the ID number is the primary k
a primary key; Score Table (School number, course number, score) A single attribute in the score table cannot uniquely identify a record, and the combination of the study number and course number uniquely identifies a record, so the attribute group for the study number and course number is a primary key. The school number in the score table is not the primary key
timetable.
The primary key and foreign keys are defined primarily to maintain the integrity of the relational database, summarizing:
A primary key is a unique identifier that determines a record, for example, a record includes an identity plus, name, and age. The ID number is the only one who can be sure of you, and others may have duplicates, so the ID number
number, course number, score)A single attribute in the score table cannot uniquely identify a record, and the combination of the study number and course number uniquely identifies a record, so the attribute group for the study number and course number is a primary keyThe school number in the score table is not the primary key of the score table, but it corresponds to the student's number, and the student's table is the primary
and check whether there is any cross-reference relationship between data tables affected. Based on the specific declaration of Foreign keys, there are two final results of the data record deletion operation: 1. This operation is not allowed; the second is to delete all data records related to other data tables. Which option you use depends on which option you use.
The following SQLCodeDemonstrate how to add Consistency Principles (
a field that determines the record of another table, which is used to maintain data consistency. For example, a field in a table is the primary key of table B, so he can be a foreign key to table A.Ii. differences between primary key
This article mainly introduces the difference and connection between the primary key and the foreign key in MySQL. it is the basic knowledge in MySQL beginners. if you need it, you can refer to the relationship between the primary key and the foreign
MySQL creates a primary key, a foreign key, and a composite primary key. For more information, see.
MySQL creates a primary key, a foreign key, and a composite primary
database level. They are the database implementation method of "Reference integrity" as described in the basic database theory.
Foreign key attributes can certainly be removed. If you don't want to use these constraints, it will certainly not affect programming, however, the "reference integrity" check is not performed for the input data.
For example, there are two tables
A (A, B): A is the primary
Primary key: There are several attributes in the record, and if one of the attribute groups (note is a group) can uniquely identify a record, the attribute group can become a primary key;PRIMARY key //primary keyYour foreign key is the primary
in the table does not have a foreign key associated with it).index is used to quickly look for records that have a specific value. Mainly for the convenience of retrieval, is to speed up access, according to certain rules created, generally play the role of sorting. The so-called Uniqueness Index , which is basically the same as the previous "normal index", has
curriculum.Primary keys and foreign keys are defined primarily to maintain the integrity of the relational database.Summarize1. A primary key is a unique identifier that can determine a record. For example, a record includes an identity plus, last nameName, age.The ID number is the only one who can determine who you are. Others may have duplicates, so the ID numberis the primary
contains the item ID field, the item ID field also exists in the item table of document 2. If the foreign key is not pulled, after the item with the item ID 3 is used in document 1 and 2, the product name cannot be found when the document is 1 or 2.
When there are few tables, some people think that data integrity and
A basic table new two tables: Table1 and table2
Table 1 (id,uid,name), the UID is a set of foreign keys, the foreign key does not have to set the automatic self increase and unsigned place do not draw √. ID as the primary key, set to self increase.
Table2 (Uid,name), the UID is set to self increase.
Note (the Table1
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.