Primary key and foreign key
Primary key: Is an index, help us quickly find, in the database to take out a column as the primary key, data is the only non-repeatable data can not be empty data, slowing down the new data
Right-click Table, point design, right-click column, set as primary key
Primary KEY Key Key
A foreign key is a constraint that constrains the source of a column of data from another table, which requires a column that is uniquely labeled
Unique (Make a column of data unique)
Remove the reference from the foreign key before deleting the data from the primary key
Identity (+)
Identity specification (is identity) identity seed (set int type)
Paradigm
The first paradigm: each column of data content to be single, unified
The second paradigm: try to relate directly to the primary key (the data from the foreign key table comes from the primary key list)
The third paradigm: the primary key as far as possible to reflect the data inside the table
CREATE TABLE Score
{
Code int PRIMARY KEY,
SCODE int references student (code),
Course varchar (20),
Score Decimal (18,2) Unique
}
Unquestionably
Condition query: Select *from student where code=1
Select *from Student where code>2
The meaning of or in the query (for logical operators)
Math operator: +-*/% (% = remainder)
Assignment operator: =
Comparison operators: >=, <=,! =,!<,!>, <>, <, >
Logical operators: And OR
SQL primary key, foreign key, normal form, query, operator