2, Eighth week-network programming advanced-Understanding of database type

Source: Internet
Author: User
Tags microsoft sql server

Objective

1. Relational database and non-relational database

A, what is a database?

A database is a warehouse of data. The main difference between a database and a common file system is that the database can quickly find the corresponding data.

B, what is a relational database?

A relational database is a database that is created from a relational model. The so-called relationship model is "a pair of one or one-to-many, many-to-many" relational model, the relationship model refers to a two-dimensional tabular model, and thus a relational database is a two-dimensional table and the relationship between a data organization. The relational model includes the data structure (the problem of the datastore, the two-dimensional table), the set of Operations instructions (SQL statement), the integrity constraint (the data constraint in the table, the constraint between the table and the table).

A common relational database:

Oracle, DB2, PostgreSQL, Microsoft SQL Server, Microsoft Access, MySQL

The characteristics of a relational database:

    • Safe (because it is stored on disk, it does not say that suddenly the power loss data is gone);
    • Easy to understand (built on relational models);
    • But not space-saving (because it is based on a relational model, you have to follow certain rules, like the data in which a field value is allocated space even if it is empty)

C, what is a non-relational database?

Non-relational database is mainly based on the "non-relational model" of the database (because the relationship is too large, so the general "non-relational" to represent other types of databases).

Non-relational models such as:

    • Column model: The stored data is a column of columns. The relational database takes one row as a record, and the column model database is listed as a single record. (This model, data is index, IO is very fast, mainly some distributed database)
    • Key-value pair model: The stored data is a "key-value pair", k/v mode.
    • Document Class Model: stores data in a document, somewhat like a "key-value pair."

Common non-relational model databases:

    • Column model: Hbase
    • Key-value pair model: Redis,memcachedb
    • Document Class Model: MongoDB

Features of non-relational databases:

    • High efficiency (because it is stored in memory).
    • But not safe (power loss data, but where redis can synchronize data to disk), many non-relational databases are now starting to support dump to disk.

2. Introduction to NoSQL Cache database

NoSQL (NoSQL = not-only sql), meaning "not just SQL", refers to non-relational databases.

Four categories of NoSQL databases:

    • Key value (Key-value) stores the database: The database is primarily used to a hash table with a specific key and a pointer to the specific data. The advantage of the Key/value model for IT systems is simplicity and ease of deployment. such as: Tokyo cabinet/tyrant, Redis, Voldemort, Oracle BDB.
    • Columnstore database: A database is often a massive amount of data used to address distributed storage. Keys still exist, but they are characterized by pointing to multiple columns. such as: Cassandra, HBase, Riak.
    • Document database: A document Database model is a versioned document, and semi-structured documents are stored in a specific format, such as JSON. A document database can be considered an upgraded version of a key-value database, allowing for the nesting of key values. and the document database is more efficient than the key-value database query. such as: CouchDB, MongoDb.
    • Graph database: The graphical structure of the database is different from the other columns and the rigid structure of the SQL database, it is using a flexible graphical model, and can be extended to multiple servers. NoSQL databases do not have a standard query language (SQL), so database queries require a data model. Many NoSQL databases have rest-type data interfaces or query APIs. such as: neo4j, Infogrid, Infinite Graph.

NoSQL databases are more appropriate in these cases:

    • The data model is relatively simple;
    • Need for more flexible IT systems;
    • The database performance requirements are high;
    • No need for high data consistency;
    • For a given key, it is easier to map the environment for complex values.

Four classified tabular analysis of NoSQL databases:

3. Mongodb\redis\memcached Difference

Redis and Memcache differences:

    • Both Redis and Memcache store data in memory, both in-memory databases. But memcache can also be used to cache other things, examples, videos, and so on.
    • Data type--memcache Specify the byte length of the data when adding data; Redis does not need to.
    • Virtual Memory--redis When the physical memory is exhausted, you can swap some long-unused value to disk. LRU algorithm.
    • Expiration policy--memcache is specified when set, such as set Key1 0 0 8, which never expires. Redis can be set by example expire, for example expire name 10
    • Distributed-set memcache cluster, use Magent to do a master multi-slave, Redis can do a master multi-slave. Can be a master one from
    • Storage data security--memcache after hanging, the data is gone; Redis can be saved to disk periodically (persisted).
    • After the disaster recovery--memcache hangs, the data cannot be recovered; Redis data can be recovered by aof after it is lost.

The three differences are as follows:

2, Eighth week-network programming advanced-Understanding of database type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.