MYSQL must know the first chapter (BASICS) of Reading Notes, mysql must know

Source: Internet
Author: User

MYSQL must know the first chapter (BASICS) of Reading Notes, mysql must know

1.1 What is a database

A database is a collection of data stored in an organized manner. A container that stores organized data (usually a file or a group of files)

Note: people usually use databases to represent the database software they use. In fact, this is incorrect. Specifically, database software should become a DBMS (Database Management System ). A database is a container created and operated by a DBMS. A database can be a file stored on a hardware device, but it can also be a file. To a large extent, whether a database is a file or something is not important, because you do not directly access the database; you use a DBMS, which accesses the database for you.

Table 1.2

A structured list of a specific type of data in a table.

Note: The uniqueness depends on multiple factors, such as the combination of Database Name and table name. This indicates that the same table name cannot be used twice in the same database, but the same table name can be used for queries in different databases.
A table has some features that define how data is stored in a table, what data can be stored, how data is decomposed, and how information about each part is named. This set of information describing a table is the so-called mode. The mode can be used to describe a specific table in the database and the entire database (the relationship with the table)

1.3 Mode

Schema is information about the layout and features of databases and tables.

Note: the mode or database is used as the synonym for the database. Unfortunately, the meaning of a pattern is usually not very clear in the context.

1.4 Columns

A field in the column table. All tables are composed of one or more columns.

Note: Data is decomposed. It is extremely important to correctly split the data into multiple columns. For example, cities, states, and postal codes should always be independent columns. By breaking it apart, it is possible to sort and filter data in a specific queue.

1.5 Data Type

The data type allowed by the Data Type (dataType. Each table column has a corresponding data type, which limits the data stored in this column.

1.6 rows

A record in the row table.

Note: is it a record or a row? You may hear that the user calls it a database record when talking about the row. To a large extent, these two terms can replace each other, but technically, the line is the correct term.

1.7 primary key

The value of a primary key column (or a group of columns) uniquely identifies each row in the table.

Note: Primary keys should always be defined. Although not all primary keys are required, most database designers should ensure that each table they create has a primary key, it facilitates data operation and management in the future.

Any column in the table can be used as the primary key as long as it meets the following conditions:

* Any two rows do not have the same primary key value.

* Each row must have a primary key value (the column with the primary key value does not allow NULL values)

The rules here are enforced by MySQL itself.

Good habits of using primary key values:

1. Do not update the values in the primary key column.

2. Do not reuse the value of the primary key column;

3. Do not use the value that may be changed in the primary key column. (For example, if you use a name as the primary key to identify a supplier, you must change the primary key when you change the supplier to merge and change its name)

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.