I. Basic introduction of database

Objective: To understand the functions of database and common database categories and database products

  • Basic Database knowledge
  • Database classification
  • The SQL profile
  • MySQL access

1. Basic knowledge of database

Objective: To understand the concepts and functions of databases

concept

The database (DB) is a repository for storing data

  • A database organizes, stores, and manages data according to data structures
  • The database can manage and store data for a long time and efficiently
  • The purpose of a database is to be able to store (write) and provide (read) data

2. Database classification

Objective: To understand the classification mode of the database, and the basis of classification

concept

Database classification: Classifies databases according to their architecture and data organization principles

1. Classification of storage model of data organized by database in the early stage

  • Hierarchical database: Hierarchical data structure (data layering)
  • Mesh database: Data structure based on mesh (data network)
  • Relational Database: Data structure based on Relational Model (TWO-DIMENSIONAL table)

2, now more according to the actual data management model classification (storage media)

  • Relational databases: Data structures (two-dimensional tables) based on relational models are usually stored on disk
  • Non-relational databases: Data structures (key-value pairs) without a concrete model are usually stored in memory

3. Relational databases

Objective: To understand the model logic of relational databases and the current popular relational database products

concept

Relational database: a database built on a relational model

  • The relational model
    • Relational data structures (storage)
    • Set of relational operations (operations)
    • Relational integrity constraints (constraints)
  • Relational databases are stored on disk (persistent storage)
  • The relational database system (DBS) model has four layers
    • DataBase Management System (DBMS) : DataBase Management System
    • Database (DB) : Manager of a data store (small management, managed by the DBMS)
    • Table: Data relationship manager
    • Data Field: The actual data store dependent on the data table
  • Relational database products
    • Large: Oracle and DB2
    • Medium: MySQL and SqlServer
    • Small: Sybase and Access

4. Non-relational databases

Objective: To understand non-relational database concepts and some of the leading products

concept

Non-relational databases: NoSQL (Not only SQL), Not just relational databases

  • All names that are not relational databases
  • The data storage model is not a two-dimensional table but a key->value pair.
  • The storage location is usually in memory (efficient)
  • Cannot be stored permanently (needs to be stored periodically in a relational database)
  • Common non-relational database products
    • MongoDB
    • Redis
    • Memcached

contrast

NoSQL is usually used in conjunction with relational databases, which are complementary to each other

  • NoSQL runs in memory to solve efficiency problems
    • I/O problems
    • The efficiency problem
  • MySQL runs on disk to solve stability problems
    • Security issues (permanent storage)
    • stable

summary

1. NoSQL is a general name for non-relational databases

  • NoSQL is more than just a relational database

NoSQL usually runs in memory

  • High read efficiency
  • High concurrent access
  • Poor stability (loss of power)

3. NoSQL typically stores data in key-value pairs and is relatively easy to access

5. Basic introduction to SQL

Objective: To understand the role of SQL and the basic classification of SQL

concept

SQL: Structured Query Language (SQL) is a standardized programming Language for relational databases

  • SQL is a programming language

  • Can realize user database query and program design

  • SQL is divided into several categories, depending on the operation
    • DQL: Data Query Language, used to Query and retrieve Data
    • DML: Data Manipulation Language, used for Data Manipulation (adding, deleting and modifying)
    • DDL: Data Definition Language, used to create Data structures
    • DCL: Data Control Language, used for user rights management
    • TPL: Transaction Process Language, which assists DML in Transaction operations (and therefore also belongs to DML)

summary

1, ALTHOUGH SQL is a programming language, but currently database is usually only used for data management (logic part to other programming languages)

2, ALTHOUGH SQL is a general language for relational database, but different product operation instructions are not completely common

6. Basic introduction to MySQL

Objective: To understand the software architecture and access principles of MySQL products

concept

MySQL: is a relational database owned by AB Company of Sweden

  • MySQL is owned by Oracle (AB->Sun->Oracle).
  • MySQL open source and free (partial storage engine)
  • MySQL is a KIND of C/S structure software, so it needs the MySQL client to access the server (data management).
    • Mysqld. exe: server
    • Mysql. exe: client
  • MySQL uses SQL instructions to operate on the database

Access to the principle of

SDB --> SDB --> SDB --> SDB --> SDB --> SDB --> SDB --> SDB --> SDB --> SDB --> SDB --> SDB --> SDB --> SDB D-->E(server)

summary

MySQL is a popular relational database

2, MySQL is a C/S structure of the software, the client to access the server

MySQL is based on SQL instructions for management operations

7, MySQL access

Objective: To master the basic operations of the MySQL client to access the server, and understand the meanings and operations of MySQL exit

concept

MySQL access: the client connects to the server, and then realizes the data operation process

  • The client accesses the server

    • Access from the Windows Console (MySQL client)
    • Leveraging database Management tools (Navicat)
  • The client requires connection authentication

    • -h: host address (local localhost can be omitted)
    • -p: port number (3306 can be omitted by default)
    • -u: indicates the user name
    • -p: indicates the user password
  • MySQL login

    1. Mysql -uroot -p Password
    2. Mysql-hip-uroot -p Specifies the password of the connection target
    3. Mysql –host= IP –user=root –password= connect target password
  • If the client connects to the server, it occupies a resource and can perform operations with corresponding permissions

    • The connection resources of the MySQL database are limited: a single server has a maximum of 16,384 connections
    • If connection resources are insufficient, other access needs to queue up
    • Release as many resources as possible
  • The client exits the server

    • \q
    • quit
    • exit

steps

1, open the client (CMD console) : mysql.exe

2. Enter server information (connection) and user information (authentication)

3. Perform SQL operations

4. Disconnect

summary

MySQL requires server access through the client

  • Mysql. exe: Use CMD in Windows
  • Database management tools: Navicat, graphical management
  • Support MySQL extension programming languages: PHP, Java, etc

2. Database operation requires connection authentication

  • Host address: -h. Default localhost can be omitted
  • Port: -p (uppercase letter). By default, 3306 can be omitted
  • User name: -u
  • Password: -p (lowercase letters)

3. Database connection resources are limited and will be closed when used up

8, summary

1, the role of the database to be clear: efficient storage and management of data, to provide data support for programming languages

2. There are two main categories of database on the market

  • Relational databases: Focus on structure and persistence of data storage
  • Non-relational databases: Focus on efficient data reading

3, relational database is almost all websites will use, must grasp its concept

4, All relational databases are based on SQL data operations, MySQL database is also (different database products corresponding to the SQL instructions may be slightly different)

MySQL is a KIND of C/S structure software, so visitors must access through the client

  • The client and server are usually not on the same computer
  • Client access to server requires addressing, authorization (-hPUP)
  • The number of connections to the MySQL server is limited.