A career success, only 15% is its professional skills, the other 85% to rely on interpersonal relationships. Relatively speaking, professional skills are hard skills, good at dealing with interpersonal skills are soft skills. --Carnegie
This is a maxim of the Carnegie, tell us, do not always develop a single one, but to more, comprehensive development!
Here are some concepts and how to organize data with tables in a database:
The four types of constraints that 1.SQL server provides:
(1) Entity integrity constraints: The entity integrity constraint is to require that each row of data in the table reflect different entities, that the same data rows cannot exist, and that the integrity of the data rows is mainly set;
(2) Domain integrity constraint: Refers to the validity of a given column input, mainly for the integrity of data column settings;
(3) Referential integrity constraint: When entering or deleting a data row, referential integrity constraints are used to maintain a defined annoying relationship between tables, saying that a simple point is a foreign key constraint;
(4) Custom integrity constraints: User-defined integrity is used to define specific rules;
2. Primary key and foreign key:
(1) PRIMARY KEY : A table can have only one primary key, and the primary key column does not allow null values (NULL), although there are no primary keys allowed in some tables, it is generally recommended that the table be set as the primary key;
Here's how to set the primary key:
(2) foreign key : in relation to the primary key, the column corresponding to the primary table in the table, called the foreign key or reference key from the table, whose value requires the primary key or unique key of the primary table to correspond, the foreign key is used to enforce referential integrity. A table can have multiple foreign keys;
Here's a demonstration of how to use foreign keys:
(1: Create two tables first;
(2: Set the primary key in the name table;
(3: In the EMP table in the blank place right click, click on the relationship;
(4: Click Add after entering the page, then follow up;
(5: can not give the primary key class manually to the value, this value is automatically given by the system.)
PS: In a table, a column in table A is the primary key, but in another table, table B, the column is not a primary key. Table A is called the primary key table, and table B is called the Foreign key table.
Next is how to create a table:
1. We use SQL database is actually using many tables, the database is composed of tables, and the data is presented in the form of a table, the table is a collection of columns is also the container of information data , many tables constitute a database. This article explains how to use tables to organize data to make the structure of the database complete.
Let's take a case example: Build a Student database table to explain how to create a database to organize data using tables.
2. When creating a table, you must be integrity-compliant. We should pay attention to the integrity of the data when we create the table organization data, which is the basis of creating a well-structured database, a well-structured database whose data integrity is perfect so that it can be maintained and used later, so we need to pay attention when creating the table.
3. provide four kinds of constraint guarantee integrity
4. Diagram of the four tables created:
The above is how to create a table and a description of the primary key and foreign key, I hope you have a little help.
When most people are concerned about you fly high not high, only a few people care about you fly tired not tired, this is friendship.
Table of the database