the "foreign key". For example: There is a "student table" has a student ID, there is a "curriculum" has a course ID, then, "Score table" is the "association table", which is associated with the student table and curriculum, in the score table, student ID and course ID is called "foreign key" it together to form a primary key. 9. Use ENUM instead of VARCHAR The ENUM type is very fast and compact. In fact,
the database as its primary key, and the best is an int type (recommended to use unsigned), and set the automatically added Auto_increment flag.Even if you have a field in the users table that has a primary key called "email", you don't have to make it a primary key. Use the VARCHAR type to degrade performance when the primary key is used. In addition, in your program, you should use the ID of the table to construct your data structure.Also, under the MySQL data engine, there are some operation
The design of the table conforms to the three paradigms
Each column property is an indivisible property value, ensuring the atomicity of each columnStudent Number name Gender contact20080901 Three men Email:[email protected],phone:8888666620080902 li si female email:[email protected],phone:66668888The above table does not conform to the first paradigm: the Contact field can be re-divided, so the change to correct is:Student number name Sex email phone20080901 three men [email protected]
this case, there is only one exception, which is the "foreign key" of the "association table", that is, the primary key of the table, which consists of the primary key of several other tables. We call this the "foreign key". For example: There is a "student table" has a student ID, there is a "curriculum" has a course ID, then, "Score table" is the "association table", which is associated with the student table and
for each table We should set an ID for each table in the database as its primary key, and the best is an int type (recommended to use unsigned), and set the automatically added Auto_increment flag.Even if you have a field in the users table that has a primary key called "email", you don't have to make it a primary key. Use the VARCHAR type to degrade performance when the primary key is used. In addition, in your program, you should use the ID of the table to construct your data structure.Also,
some business queries, less than 10%.
Experience: Let the right software do the right thing, don't just think about optimization from the technical level, but also from the needs of the decomposition.Summary in the SUMMARYTurn a very classic database optimization funnel law, many years ago saw, and now look still feel applicable, we encourage each other.The only thing that doesn't apply is the bottom-up increase in resources, SSDs are really a good thing, who knows who to use.QuestionQ:mys
case, there is only one exception, which is the "foreign key" of the "association table", that is, the primary key of the table, which consists of the primary key of several other tables. We call this the "foreign key". For example: There is a "student table" has a student ID, there is a "curriculum" has a course ID, then, "Score table" is the "association table", which is associated with the student table and cu
Tags: each null data class tab teacher name add nbsp --Create a student situation table and add dataCREATE TABLE Student (Sno varchar) PRIMARY KEY, Sname varchar () NOT NULL, Ssex VARCHAR (a) NOT NULL,
Sbirthday DATETIME, Class VARCHAR ()) DELETE from student;
SELECT * from student;
INSERT into student VALUES (108, ' Zeng Hua ', ' Male ', ' 1977-09-01 ', 95033);
INSERT into student VALUES (105, ' Kuanming ', ' Male ', ' 1975-10-02 ', 95031);
INSERT into student VALUES (107, ' Wang Li ', ' female
when the primary key is used. In addition, in your program, you should use the ID of the table to construct your data structure. Also, under the MySQL data engine, there are some operations that need to use primary keys, in which case the performance and settings of the primary key become very important, such as clustering, partitioning ... In this case, there is only one exception, which is the "foreign key" of the "association table", that is, the primary key of the table, which consists of t
* from course;SELECT * from student; --Student Table association to Grade table student table from table, Grade table is main table--Increase the foreign Key associationALTER TABLE student ADD constraint Fk_stu_grade foreign key (Gradeid)References Grade (Gradeid)--Curriculum is associated to the Grade table curriculum is from the table, the grade table is the main tableALTER TABLE COURSE add constraint fk
the basis of the student table and curriculum, the school schedule is added to indicate the many-to-many relationship between students and the curriculum. The attributes that must be included in the selected schedule are the student number and the course number. (Student number, course number) This attribute set is just the keyword for choosing a timetable.code example:--Create student tablesCREATE TABLE S
Label: This article reproduced from:http://www.cnblogs.com/longyi1234/archive/2010/03/24/1693738.html Blue Sky First, what is the primary key, foreign key relational database in a record in a number of attributes, ifAn attribute group (note is a group) can uniquely identify a record, the property group can become a primary keyFor example: Student Table (school number, name, gender, Class) Each student's school number is unique, the study number is a primary key
Tags: Gets SQL Server graphics create change COM single column note let Although the ORM mapping is used in the project, the optimization of the Oracle system is very valuable, and here is a summary of the frequently used statements from the perspective of the SQL statement. 1. Optimizations in the From field:Oracle Yasuteru Loading table data from right to left, you should put the table that can exclude the most data to the back (the underlying table).Example. In the associated query. Put the
type (recommended to use unsigned), and set the automatically added Auto_increment flag. Even if you have a field in the users table that has a primary key called "email", you don't have to make it a primary key. Use the varchar type to degrade performance when the primary key is used. In addition, in your program, you should use the ID of the table to construct your data structure. Also, under the MySQL data engine, there are some operations that need to use primary keys, in which case the per
multi-party--If I need to find out which department all the employees belong to--A Department of staff:--SELECT * from Department D, the staff s where d.staff_id = S.id;--Query All employees:SELECT * FROM Department D, the staff s where d.id = s.department_id;--Find out the number of employees in each department--First step: Find out the Department--The second step: to find out the related table of the Department--Step three: need to group departmentsSelect D.name, COUNT (1) from Department D,
ID, there is a "curriculum" has a course ID, then, "Score table" is the "association table", which is associated with the student table and curriculum, in the score table, student ID and course ID is called "foreign key" it together to form a primary key.9. Use ENUM instead of VARCHARThe ENUM type is very fast and compact. In fact, it holds the TINYINT, but it appears as a string on its appearance. In this
should use the table's primary key to construct your data mechanism. Also, under the MySQL data engine, there are some operations that need to use primary keys, in which case the performance and setting of the primary key becomes very important, such as clustering, partitioning .... ) In this case, there is only one exception, which is the "foreign key" of the "association table", that is, the primary key of the table, which consists of the primary key of several other tables. We call this the
consists of the primary key of several other tables. We call this the "foreign key". For example: There is a "student table" has a student ID, there is a "curriculum" has a course ID, then, "Score table" is the "association table", which is associated with the student table and curriculum, in the score table, student ID and course ID is called "foreign key" it together to form a primary key.9. Use ENUM ins
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.