当前位置:网站首页>First day of database

First day of database

2022-06-11 07:00:00 Yu Mei

2021.6.15 Learn the first 60 God , Access to the database , stay node.js On the fifth day , I don't feel much ,nodejs It can be regarded as a backstage course , Why should the front end learn nodejs, It is natural to understand the front and rear interfaces , For a small project , use nodejs You can do it , There are also database operations , Simply put, it means adding, deleting, modifying, and querying , according to the understanding of , It's very important . A database is the place where data is stored , Then store the data with txt All right. , Why have databases ?

1. Basic concepts of database

1.1 What is a database

  1. database (database) It's for organizing 、 Warehouse for storing and managing data
  2. In order to facilitate the management of data in the Internet world , There is the concept of database management system ( abbreviation : database ). Users can add data in the database 、 Inquire about 、 to update 、 Delete and other operations

1.2 Common databases and classifications

  1. Common databases are divided into the following categories :
    · MySQL database ( At present, it is most widely used 、 The most popular open source free database ;Community + Enterprise)
    · Oracle database ( charge )
    · SQL Server database ( charge )
    · Mongodb database (Community + Enterprise)
  2. Database classification
    1. Traditional database ( Relational database or SQL database )
      · MySQL、Oracle、SQL Server, The design concepts of the three are the same , The usage is similar
    2. New database ( Non relational database or NoSQL database )
      · Mongodb, To some extent, it makes up for the defects of traditional database

1.3 The data organization structure of traditional database

  1. In a traditional type of database , The organizational structure of data is divided into database (database)、 Data sheet (table)、 data row (row)、 Field (field) this 4 Most of the components

 Insert picture description here

  1. Concept object

    * A database is similar to Excel The workbook for
    * The data table is similar to Excel The worksheet for
    * Data rows are similar to Excel Each row of data
    * Fields are similar to Excel The column of
    * Each field has a corresponding data type

1.4 Library in actual development 、 surface 、 That's ok 、 Field relationship

  1. In actual project development , In general , Each project corresponds to a separate database
  2. Different data , To store in different tables in the database , for example : User data is stored in users In the table , Store book data in books In the table
  3. What information is stored in each table , Determined by the field , for example : We can users Table design id、username、password this 3 A field
  4. The rows in the table , Represents each specific piece of data

2. install MySQL

2.1 Know what needs to be installed MySQL Related software
For developers , Just install MySQL Server and MySQL Workbench These two pieces of software , Can meet the needs of development

  • MySQL Server: Software specifically designed to provide data storage and services
  • MySQL Workbench: Visual MySQL Management tools , Through it , It can be easily operated and stored in MySQL Server Data in

2.2 MySQL stay Mac Installation in environment

stay Mac Installation in environment MySQL It's better than Windows The steps in the environment are much simpler

  • First run mysql-8.0.19-macos10.15-x86_64.dmg This installation package , take MySQL Server The installation to Mac System
  • Run again mysql-workbench-community-8.0.19-macos-x86_64.dmg This installation package , Will be visualized MySQL Workbench Install the tool to Mac System
  • Specific installation tutorial , You can refer to mac System installation mysql database

2.3 MySQL stay Windows Installation in environment

  1. stay Windows Installation in environment MySQL, Just run mysql-installer-community-8.0.19.0.msi This installation package , You can put MySQL Server and MySQL Workbench Install on your own computer
  2. Specific installation tutorial , You can refer to win10 System installation mysql Methods

3.MySQL Basic use of

3.1 Use MySQL Workbench Management database

  1. Click on window key , Find all apps , Found installed MySQL Workbench, Click to
  2. Connect the database as shown
     Insert picture description here

3.2 Create database

  1. Steps to create a database
  • Click the create library button
  • Fill in the name of the database
  • Click on Apply Button , Create database
  1. Create database diagram
     Insert picture description here

3.3 Create data table

 Click on  Table  Table right key , Pop up  create Table  You can create a data table 

3.4 Field name and data type of design table

DataType Common data types :

  • int Integers
  • varchar(len) character string
  • tinyint(1) Boolean value

3.5 Set the special identification of the field

  1. Set the special identification of the field

    • PK(Primary Key) — Primary key 、 Unique identification
    • NN(Not Null) — Value cannot be empty
    • UQ(Unique) — It's worth it
    • AI(Auto Increment) — The value increases automatically
  2. Set the special identification of the field according to the figure
     Insert picture description here
    3.6 Write data to the table
    Write data to the table as shown
     Insert picture description here

4.SQL sentence

4.1 What is? SQL

  1. SQL yes Structured query language , A programming language designed to access and process databases . Can let us in the form of programming , Operate the data in the database
  2. Three key points :
    • SQL Is a database programming language
    • Use SQL Language code , be called SQL sentence
    • SQL Language can only be used in relational databases ( for example MySQL、Oracle、SQL Server). Non relational database ( for example Mongodb) I won't support it SQL Language

4.2 SQL What can be done

  1. Query data from database
  2. Insert new data into the database
  3. Update the data in the database
  4. Delete data from database
  5. You can create a new database
  6. New tables can be created in the database
  7. You can create stored procedures in the database 、 View

See you next time ······

原网站

版权声明
本文为[Yu Mei]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020524235000.html