The database Foundation uses the database, must first must put WAMPW
The server software is turned on or the database cannot be used.
If you want to resume a new database, right-click on the right-hand side of Navicat 8 for MySQL and select Create DATABASE. Enter the name of the database, the character set select Utf8--utf-8-unicode, and click OK to create a new database. Double-click the database name to open the database. The database is stored in tabular form when the data is stored.
Double-click the name of the database will come out of the database options, put the mouse on the table, right-click to select Create TABLE, click the Pop-up dialog box, in the dialog box you can choose to create a table. When you create a table, you specify what information is stored in the table, and the information that is stored is determined by the column, so when you create the table, the column information is filled in. The information in the database should not be used in Chinese, generally in English, but also in pinyin. Try to use lowercase letters, preferably prefixed with prefix, to avoid post-release to the server a large number of changes. For example, the operating system is written as a zy_ table name, usually separated by an underscore, the rules are stipulated.
Create the interface of the table, the name of the column below, written in English or letters, you can remember. Type below write data type, database storage data and excle table is not the same, excle table storage is more arbitrary, and the database is more rigorous storage data, required to build a column of input content to be planned beforehand. The string in the database is varchar, the string needs to write length, the other can not write the length, after selecting the varchar later write the length. The general common length is 20 and 50, the short setting is 20, and the long setting is 50. There is another option is "Allow null value", meaning is not allowed to fill, marked with a checkmark can not fill, remove the check mark this column must be filled, do not fill the words stored. Build the next column and click Create field or Insert field.
If you want to store the data in the table, double-click the Open table and the name of the column that will appear when you open the table. After writing the data, click the checkmark below to save the data.
A data table must have a primary key to uniquely represent this data, select the primary key to be established and click on the primary key above, the primary key column will appear on the last side of a key identification. The primary key is used to control that the table cannot fill in duplicate information. A primary key is added to each table.
The self-growth column has no meaning, just to differentiate each piece of data, the name is generally called IDs. Select self-increment after selection of the following automatic increments, you will fill up, do not fill in the data. Generally used in the table bad Brahma key, each column can not be a primary key.
Foreign key, the foreign key must have 2 tables, the 2 tables must have a relationship. These 2 tables can become the main table and from the table, the table that restricts another table is called the main table, the constrained table is called from the table, and the master table is controlled from the table.
The foreign key column in the primary table must be a primary key.
The role of foreign keys in the database is to make the data more secure. If a foreign key relationship is established, the contents of the main table cannot be deleted arbitrarily, and if a column is deleted, then the table associated with this column will be affected by the problem. If you want to delete the contents of the main table, you have to delete all the data that was contacted first.
The main table can not be casually moved from the table.
1. Rules for building tables
Three main paradigms of database
First paradigm: Guaranteeing the atomicity of each column
Second paradigm: Ensure that each column of a data table is associated with a primary key
Third paradigm: Ensure that each column of the data table is directly related to the primary key
Experience Summary:
1. Be able to disassemble the table as far as possible, remove it until it cannot be removed.
2. Table name prefix when establishing the table, preferably lowercase (only for wampserver database)
3. If the primary key is not found, use the self-growing column.
4. Foreign key relationship can not be added
1014 PM Database Basics