First acquaintance with database, database management system and SQL

1. Database and database management system

What is a database? Below we give the definition of the database

Database shorthand: DB, it is a collection of data stored in an organized manner. We can understand it as a container for storing organized data

Database management system (DBMS) , a database is a container created and operated by a DBMS. To a large extent, you do not need to directly access the database. When you use a DBMS, he accesses the database for you

 

Second, the components of the database

Table: A structured list of data of a particular type. Each table in the database has its own name, which is unique.

Column (column): a field in a table, all tables are composed of one or more columns, a specific piece of information stored in the column of the table. For example, in the customer table, one column stores the customer number, and the other column stores the customer name. It is extremely important to correctly decompose the data into multiple columns, so it is also very convenient to search by condition

Data type (datatype): Each column in the table has a corresponding data type, which limits the data stored in the column (for example, to prevent numeric fields from being entered into character values), so special attention must be paid to the data type when creating the table

Row (row): The data in the row is stored by row, he saves each record, for example, each row of the customer table records all the information of a customer, the number of rows in the table is the total number of records

The primary key (primary key): a column or group of columns, the value of which can uniquely distinguish each row in the table, the column (or group of columns) that uniquely identifies each row in the table is called the primary key

Each row in the table should have a column that uniquely represents itself, a customer table can use the customer number column, and an order table can use the order ID. If there is no primary key, it will be difficult to update or delete specific rows in the table, because there is no safe way to ensure that only the relevant rows are involved

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

  1. No two rows have the same primary key value
  2. Each row must have a primary key value (primary key columns do not allow NULL values)

 

Third, what is SQL

SQL is an abbreviation of Structured Query Language (Structured Query Language) , which is a language specifically used to communicate with databases.

Unlike other programming languages, SQL is composed of very few words. This is intentional. When designing the purpose of SQL, it is a good task to complete, that is, to provide a simple and effective method to read and write data from the database.

The advantages of SQL:

  • SQL is not the proprietary language of a particular database vendor, and almost all DBMSs support SQL.
  • SQL is simple and easy to learn, its sentences are composed of very descriptive English words
  • Although SQL looks simple, it is a powerful language that can perform very complex and advanced database operations

Attachment: In fact, the SQL implemented by any two DBMS is not the same. The SQL mentioned below is specifically for MYSQL, so do n’t think that these SQL syntax can be completely transplanted.

The SQL statement is composed of words, some words are necessary, some are optional, a word is usually composed of a keyword and the data provided, such as the FROM clause in the SELECT statement, the end statement of the SQL statement must add points number;

SQL statements are not case-sensitive, but for ease of reading and debugging, it is recommended to use uppercase SQL keywords and lowercase for all table and column names

 

Published 138 original articles · praised 34 · 150,000 views

Guess you like

Origin blog.csdn.net/bbj12345678/article/details/105433729