Discover mysql foreign key example, include the articles, news, trends, analysis and practical advice about mysql foreign key example on alibabacloud.com
Label:the role of foreign keys The main role of foreign keys is to maintain data consistency and integrity. About foreign keys, I have some of my own understanding, but I do not know whether it is correct, for example to express my view: If you need to build a table, what kind of table it? A student's personal informat
specific principle here is not clear, the above is only speculation, hereby recordedIf you find a reason to update!Update:Https://stackoverflow.com/questions/22013511/mysql-error-1215-hy000-cannot-add-foreign-key-constraintThat is to say, my above guess is correct!Take a look at the unique test:Transferred from: http://www.cnblogs.com/Andy963/p/7634537.htmlThe l
duplicate values. For example, because a person might have the same name, it may occur two or more times in the same employee profile data table. If you can determine that a data column will contain only values that are different from each other, you should define it as a unique index with the keyword unique when creating an index for that data column. The advantage of this is that it simplifies MySQL's management of the index, which makes it more ef
Mysql -- foreign key (froeign key), mysql -- froeign
If a field of an object points to the primary key of another object, it is called a foreign key.The object to be pointed to is calle
child table.
Set null:Delete or update rows from the parent table, and set the foreign key column in the child table to NULL.. If the foreign key column does NOT specify the not null qualifier, this is unique and valid. The on delete set null and on update set null clauses are supported.
No action: in ANSI SQL-92
operations can not be nested more than 15 layers deep.divergence from the SQL standard : Similar to general MySQL, within an SQL statement that inserts, deletes, or updates many rows, InnoDB checks the unique and foreign key constraints line by row. According to the SQL standard, the default behavior should be deferred check, that is, the constraint is checked o
comparison operations. You should use 0, a special value, or an empty string instead of a null value.
Time to build the index:In general, the columns that appear in the where and join need to be indexed, but not entirely, because MySQL uses the index only for FOREIGN key:is one or more columns that are used to establish and strengthen links between two table data.
What is the foreign key in MySQL? what is the role of the foreign key in Mysql?
This article participates in the blog contest. if you are satisfied, click here to vote for me. Click here to view the original article.I recently l
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 one difference: all the values of an indexed
In-depth explanation of mysql foreign key association issues
BitsCN.com continues to read the book "mysql database development" recommended by the instructor. I encountered a problem when I saw the foreign key association problem
Cartesian productMulti-table query, multiple tables become a tableIntegrity constraint conditionsPrimary key identifies this property as the primary key for the table and can uniquely identify the corresponding tupleForeign key identifies this property as a foreign key of th
, replace with a null value (only for fields that have been marked as NOT null)RESTRICTdeny delete requirements until a secondary table using the DELETE key value is manually deleted and no reference is made (this is the default and the safest setting) No ACTION do nothing. Notice thatUPDATEAnd onDelete rule, when you set up MySQL to automate the operation, if the relationship of the
MySql multi-to-multi-link foreign key application Mysql foreign key
BitsCN.com
Business Requirements: The user table r_user stores user name and other information. Now you need to set up a work base for each user. one user can hav
This article describes the foreign key constraints in MySQL. 1 constraints Overview The purpose of creating constraints is to ensure data integrity and consistency. The constraint is divided into table-level constraints and column-level constraints based on the number of fields targeted by the constraint. If the constraints are divided by function, they are: NOTN
MYSQL foreign key (ForeignKey)
BitsCN.com
MySQL 3.23.44 and later versions support foreign key constraints for InnoDB engine tables.
Usage conditions of foreign keys:
1. the two tables
various constraints for update and delete operations:Cascade:The foreign key field values in the foreign key table are updated, or the column where the foreign key field is located is deleted.Restrict:Restrict is also equivalent
of RDBMS.
However, many users are interested in the advantages of the integrity of the reference. Recently, different versions of MySQL (the best combination with PHP) support foreign keys through the new InnoDB list engine. Therefore, it is very easy to maintain the integrity of the reference in the list of databases.
To establish a MySQL
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.