The data in a table is stored in rows, with each record saved stored in its own row.
If you think of a table as a grid, the columns in the grid are vertical and the rows are horizontal. For example, a customer table can store one customer per row. The number of rows in the table is the total number of records.
A record in a row table. Is it a record or a line? You may hear users refer to rows as database records. For the most part, the terms are interchangeable, but technically, line is the correct term.
Each row in the primary key table should have a column (or set of columns) that uniquely identifies itself. A customer table can use a customer number column, an order table can use an order ID, and an employee table can use an employee ID or an employee Social Security number. Primary key
① A column (or group of columns) whose value uniquely distinguishes each row in the table.
The column (or group of columns) that uniquely identifies each row in the table is called the primary key. A primary key is used to represent a particular row. Without a primary key, updating or deleting a particular row in a table is difficult because there is no secure way to ensure that only the relevant rows are involved.
You should always define a primary key Although you don’t always need a primary key, most database designers should ensure that each table they create has a primary key for future data manipulation and management. Any column in the table can be used as a primary key if it meets the following criteria:
1/ do not have the same primary key; 2/ Each row must have a primary key value (NULL values are not allowed for primary key columns).
Primary key value rules The rules listed here are enforced by MySQL itself. A primary key is usually defined on a single column of a table, but this is not required, and multiple columns can be used together as primary keys. When multiple columns are used as primary keys, the above conditions must apply to all columns that make up the primary key, and the combination of all column values must be unique.
Best habits for primary keys In addition to the rules MySQL enforces, a few generally accepted best habits to adhere to are: 1/ Do not update values in primary key columns; 2/ Do not reuse primary key column values; 3/ Do not use values that may change in primary key columns. For example, if a name is used as a primary key to identify a vendor, this primary key must be changed when the vendor merges and changes its name.