FOREIGN keyForeign key: The outside key, a field in the preceding table has a corresponding relationship to the field (primary key) in the other tableFOREIGN KEY keyword:
the database, which means that more complex program design logic is implemented to handle the relationships between the tables. While it is possible to simplify database access by using abstraction layers and ORM modules, the logic needed to process them becomes increasingly complex as the number of data tables required by the application increases.
So, for MySQL, is there a database-level foreign
Label:First, the basic concept 1, MySQL "key" and "index" definition is the same, so the foreign key and the primary key is also one of the index. The difference is that MySQL automatically indexes the primary key for all tables, but the
and the students is a pairRelationships, which are implemented through foreign key associations.To establish a college table and a student table, the student table has a non-empty field ss_id, which associates it to the institute's number (SCHOOL_ID), i.e. the student must belong to a certain schoolHospital. To insert data into the school table: To insert da
automatically checks to see if the value of this field in the new record has already appeared in the field of a record when a new record is inserted into the data table; MySQL will refuse to insert that new record. In other words, a unique index guarantees the uniqueness of the data record. In fact, in many cases, the goal of creating a unique index is often not to improve
I. Basic Concepts
1. MySQL has the same definition of "key" and "Index", so foreign keys and primary keys are also an index. The difference is that MySQL will automatically index the primary keys of all tables, but the foreign key field must be explicitly indexed by the us
a data table with a new record, automatically checks whether the value of this field of the new record has already exists in this field of a record; if yes, MySQL rejects the insert of that new record. That is to say, the unique index can ensure the uniqueness of data records. In fact, in many cases, the purpose of creating a unique index is not to speed up access
:
When a foreign key is related to a field in another table, and the relationship is temporary, the system is called a state of referential integrity. That is, if a field appears only once in all tables, and the change in this field of each table affects the other t
large-scale systems (performance requirements are not high, high security requirements), the use of foreign keys, in large-scale systems (high performance requirements, security control), no foreign key; small system, the best use of foreign keys.2, use the foreign
I have been developing an information equipment application management system over the past two days. When designing a database, I encountered a tangle problem, that is, the definition of foreign keys, because I don't know which fields need to be defined as foreign keys. Under what circumstances can I define foreign keys and how can I define
primary table as a foreign key, even if the primary key of the primary table should be a unique constraint field as a foreign key
Sql> ALTER TABLE Foreign_main add constraint Pk_fsid primary
This foreign key is what, it is not dispensable, feel very mysterious appearance. See a lot of experts are pointing rookie said to do a foreign key, but why do not say, on the fairy go also, hey! Only fish are not to be taught!
Reply to discussion (solution)
In the relational database, in order to reduce the redu
To add a foreign key to a table must satisfy 2 conditions, 1, the engine of the table must be innodb,2, you must index the field to which you want to add the foreign keyCREATE TABLE Child (CID int NOT NULL Auto_increment primary key,PID int,
key value is updated, it indicates that the database will spread the new key value to the corresponding foreign key field.
Cascade deletion related fields
Indicates when to delete rows in the master table.DatabaseHttp://blog.csdn.net/shanzhiziremove the corresponding line f
Create a foreign key for a Mysql Cluster. There are four constraints: noaction, restrict, cascade, and setnull. If the primary keyword of Table A is A field in Table B, this field is called the foreign key of Table B. Table A is c
KEY (`blog_id`) REFERENCES `blogs` (`id`) ON UPDATE CASCADE3637) ENGINE = InnoDB DEFAULT CHARSET = utf8;
In addition to defining some simple fields for the above two InnoDB tables, the above Code also uses a foreign key constraint, so that whenever the "id" Key of the parent table is updated, the contents
Do I have to have a foreign key in a data table in php? what is this foreign key? is it dispensable and mysterious. I can see that many experts are instructing Cainiao to say they want to create a foreign key, but if you don't wan
Original: powerdesigner-vbsrcipt-Auto set Primary key, foreign key name, etc. (SQL Server)When designing SQL Server datasheets in PowerDesigner, the following functionality is required through VBScript scripting:Primary key: Pk_tablenameFOREIGN key: Fk_tablename_foreignkeyco
/foreign key will add to the development difficulty, resulting in excessive table and other issues 3, without foreign key data management is simple, easy to operate, high performance (import and export operations, in INSERT, UPDATE, delete Data faster) Eg: in a large number of databases do not want to think about
transactions to take during development, because MyISAM tables provide excellent performance.
Of course, this is also costly. As I mentioned earlier, applications must maintain database integrity and consistency, this means implementing more complex programming logic to process the relationships between tables. Although database access can be simplified by using the abstraction layer and ORM module, the logic required to process the data tables requi
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.