You must know How to read. Chapter 1 Basics

  • 2020-12-26 05:55:50
  • OfStack

1.1 What is a database

A database (database) is a collection of data stored in some organized way. A container that holds organized data (usually 1 file or 1 set of files)

Note: People often use databases to represent the database software they use. Actually, this is not true. Rather, the database software should be called DBMS (Database management System). Databases are containers that are created and manipulated through DBMS. A database can be a file stored on a hardware device, but it may not be. For the most part, it doesn't matter whether the database is a file or something else, because you don't have direct access to the database; You're using DBMS, which accesses the database for you.

Table 1.2

Table (table) a structured list of a particular type of data.

Note: the only property indicated depends on a combination of several factors, such as the database name and the table name. This means that while you cannot use the same table name twice in the same database, query can use the same table name in different databases.
Tables have 1 set of features that define how data is stored in the table, what data can be stored, how the data is broken down, and how the information for each part is named. The set of information that describes a table is called a schema, and a schema can be used to describe a particular table in a database and the entire database (and its relationship to the tables within it)

1.3 model

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

Note: Is it a schema or a database? Sometimes a schema is synonymous with a database. Unfortunately, the meaning of a pattern is often not clear in context.

1.4 column

1 field in column (column) table. All tables consist of one or more columns.

Note: Break down the data. It is extremely important to decompose the data correctly into multiple columns. For example, city, state, and zip code should always be separate columns. By breaking it up, it is possible to sort and filter with specific queued data.

1.5 Data Type

Data type (dataType) the type of data allowed. Each table column has a corresponding data type, which limits the data stored in that column.

1.6 line

Row (row) table 1 record.

Note: Is it a record or a line? You might hear users refer to rows as database records. For the most part, the two terms are interchangeable, but technically, line is the correct term.

1.7 the primary key

Primary key (primary key) 1 column (or 1 set of columns) with a value that can distinguish each row in the table with only 1.

Note: Primary keys should always be defined. Although primary keys are not always required, most database designers should ensure that each table they create has a primary key for later data manipulation and management.

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

* No two lines have the same primary key value.

* Each row must have 1 primary key value (NULL values are not allowed for primary key columns)

The rules here are enforced by MySQL itself

Good habits for primary key values:

1. Values in the primary key column are not updated.

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

3. Do not use values that may change in the primary key column. (For example, if 1 name is used as the primary key to identify a vendor, this primary key must be changed when the vendor merges and changes its name)


Related articles: