One, the difference between database and memory
Database:
Some data files that are stored on your hard disk
Memory:
Some data that the computer temporarily stores
Second, the common database
. Net-sql Server
Php-mysql
Java-oreacl
Iii. How SQL Server is used
1. Create a new database
Right click on "Database" and click "New Database". In the pop-up page, name the new database and click Confirm.
2. New Table
Locate the newly created database, right-click on "Tables" in the new database and click "New Table". Edit column name, data type
Data type Note:
int integral type
Decimal (length, number of decimal digits) floating-point
Bit-Boolean type 1-true 0-false
DateTime-Time Date type
Date-only Dates
nvarchar (length) Max String type English letters and Chinese characters are equal in length, it is recommended to use nvarchar
varchar (length) String type
Text-long text
Image-Image type, with picture stream
Iv. Four kinds of constraint relationships in database
1. PRIMARY KEY constraint:
Set a column as the primary key column
Duplicate is not allowed, NULL is not allowed, a table has only one primary key column
In the new Table edit page, right-click the column to select Set Primary key.
2. Foreign KEY constraints: (the most important constraint for establishing relationships between tables and tables)
One of the columns of the current table is constrained by one of the primary key columns/unique columns of the other table
The contents of the column in which the current table is constrained are not allowed to exceed the contents of the column that constrains it
To constrain columns of other tables as primary constraint columns, this column must be a primary key column/Unique column
On the constrained table: Right-click on the "Design", right-click on the constrained column "relationship", click "Add", on the right "table and column Specification" Set the constraint specification, click "" ... "after" Table and column Specification "
Selecting the primary key table is the constraint table, and the foreign key table is the constrained table. Confirm and save when you are finished selecting.
3, the only constraint:
Set a column to be unique, so that the data for this column cannot be duplicated
Right-click on "Index key"---"Add"----change "is unique" to "yes"
4. Check constraint:
Write an expression that constrains the range of values in a column
Right-click on "Check Constraint"--"add"---add an expression
&&-
|| -OR
"2017-03-09" SQL Server Database Foundation, four constraints