Database Overview (Study Notes)

content

1. Database

2. Database and database management system

2.1 Concepts related to database

2.2 The relationship between database and database management system

3. Introduction to MySQL

3.1 Overview

3.2 Advantages of MySQL

4. RDBMS vs. non-RDBMS

4.1 Relational databases

4.1.1 Substance

4.1.2 Advantages

4.2 Non-relational databases

4.2.1 Introduction

4.2.2 What non-relational databases are there?

4.2.3 Evolution of NoSQL

5. Relational database design rules

5.1 Tables, records, fields

5.2 Relationship of Tables

5.2.1 One-to-one association

5.2.2 One-to-many relationship

5.2.3 Many-to-many

5.2.4 Self-reference


1. Database

  • Persistence: Save data to a power-down storage device for later use . In most cases, especially for enterprise-level applications, data persistence means saving the data in memory to the hard disk for "solidification" , and the implementation process of persistence is mostly done through various relational databases.

  • The main function of persistence is to store the data in the memory in the relational database , of course, it can also be stored in the hard disk file and XML data file.

image-20211209164210850

2. Database and database management system

2.1 Concepts related to database

DB: Database (Database)

That is, the "warehouse" for storing data, which is essentially a file system. It holds a series of organized data.

DBMS: Database Management System (Database Management System)

It is a large-scale software for manipulating and managing databases, which is used to establish, use and maintain databases, and to manage and control databases in a unified manner. Users access the data in the tables in the database through the database management system.

SQL: Structured Query Language (Structured Query Language)

A language specifically used to communicate with databases.

2.2 The relationship between database and database management system

A database management system (DBMS) can manage multiple databases, and a typical developer will create a database for each application. In order to save the data of the entities in the application, multiple tables are generally created in the database to save the data of the entity users in the program.

The relationship between database management system, database and table is shown in the figure:

image-20211209164717896

3. Introduction to MySQL

3.1 Overview

  • MySQL is an open source relational database management system .

  • MySQL is an associative database management system that keeps data in different tables instead of keeping all the data in one big warehouse, which increases speed and improves flexibility.

  • MySQL is open source. Use the standard SQL data language form.

  • MySQL supports large databases. Can handle large databases with tens of millions of records .

  • MySQL supports large databases and data warehouses with 50 million records. The 32-bit system can support 4GBthe largest table file, and the 64-bit system supports the largest table file 8TB.

3.2 Advantages of MySQL

  • Open source code, low cost to use.

  • Excellent performance and stable service.

  • The software is small in size, simple to use, and easy to maintain.

4. RDBMS vs. non-RDBMS

Type of database: relational database, non-relational database

4.1 Relational databases

4.1.1 Substance

  • This type of database is the oldest type of database, and the relational database model boils down complex data structures into simple binary relationships (that is, two-dimensional tabular forms).

  • Relational databases store data in the form of rows and columns for easy understanding by users. This series of rows and columns is called a table, and a group of tables makes up a library.

  • Tables are related to data records between tables. Various entities in the real world and various connections between entities are represented by relational models. A relational database is a database built on a relational model .

  • SQL is the query language for relational databases.

4.1.2 Advantages

  • complex query

Can do very complex data queries between one table and multiple tables

  • Transaction support

Enables the realization of data access requirements with high security performance

4.2 Non-relational databases

4.2.1 Introduction

The data is stored based on key-value pairs, and does not need to be parsed by the SQL layer, and the performance is very high. At the same time, performance is further improved by reducing infrequently used functions.

4.2.2 What non-relational databases are there?

key-value database

A key-value database stores data by means of Key-Value , where Key and Value can be simple objects or complex objects. As a unique identifier, Key has the advantage of fast search speed, which is obviously superior to relational databases in this regard. The disadvantage is that you cannot use conditional filtering (such as WHERE) like relational databases. If you don't know where to find data, you need to Iterating over all the keys consumes a lot of computation.

A typical use case for a key-value database is as a 内存缓存. Redisis the most popular key-value database.

document database

The database holds and retrieves documents. In the database, a document is the basic unit of processing information, and a document is equivalent to a record. The documents stored in the document database are equivalent to the "values" stored in the key-value database. MongoDB

search engine database

Although relational databases use indexes to improve retrieval efficiency, the efficiency of full-text indexing is low. The search engine database is a form of data storage applied in the field of search engines. Since search engines crawl a large amount of data and store it in a specific format, the optimal performance can be guaranteed during retrieval. The core principle is "inverted index" .

Typical products: Solr, Elasticsearch, Splunk, etc.

columnar database

A columnar database is a database with row-based storage. Databases such as Oracle, MySQL, and SQL Server use row-based storage (Row-based), while a columnar database stores data in the database according to columns. The advantage is that it can greatly reduce the I/O of the system, and it is suitable for distributed file systems. The disadvantage is that the function is relatively limited. Typical products: HBase, etc.

image-20211209202026511

graph database

A graph database uses the graph data structure to store the relationships between entities (objects). The most typical example of a graph database is the relationship between people in a social network. The data model is mainly implemented with nodes and edges (relationships), which are characterized by the ability to efficiently solve complex relationship problems.

A graph database, as its name suggests, is a database that stores graph relationships. It uses the graph data structure to store the relationship between entities (objects). Relational data is used to store data with clear relationships, but it is somewhat incapable of storing data with complex relationships. For example, the relationship between characters in a social network is very complicated if a relational database is used, but it is very simple with a graph database. Typical products: Neo4J, InfoGrid, etc.

image-20211209202128323

4.2.3 Evolution of NoSQL

NoSQL makes a good complement to SQL. For example, in actual development, there are many business requirements. Realistic does not require complete relational database functions, but non-relational database functions are sufficient. In this case, it is certainly a wiser choice to use a non-relational database with higher performance and lower cost. For example: log collection, leaderboards, timers , etc.

5. Relational database design rules

  • The typical data structure of a relational database is the data table , and the composition of these data tables is structured

  • Put the data into the table, and the table into the library

  • A database can have multiple tables, and each table has a name to identify itself. Table names are unique.

  • Tables have properties that define how data is stored in the table, similar to the design of classes in java and python

5.1 Tables, records, fields

  • There are three main concepts in the E-R (entity-relationship) model: entity set, attribute, and relationship set.

  • An entity set (class) corresponds to a table (table) in the database, and an entity (instance) corresponds to a row (row) in the database table, also known as a record (record). An attribute (attribute) corresponds to a column in a database table (column), also known as a field (field).

image-20211207162714815

5.2 Relationship of Tables

  • Tables are related to data records between tables. Various entities in the real world and various connections between entities are represented by relational models.

  • Four: one-to-one association, one-to-many association, many-to-many association, self-reference

5.2.1 One-to-one association

image-20211207163415949

5.2.2 One-to-many relationship

image-20211207170713619

5.2.3 Many-to-many

image-20211207171032783

5.2.4 Self-reference

image-20211207171354699

Refer to Shang Silicon Valley Song Hongkang Database Video Course

Guess you like

Origin blog.csdn.net/qq_52595134/article/details/121843351