亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

redis - 如一簡單博客數(shù)據(jù)庫,NoSQL該如何設計?
巴扎黑
巴扎黑 2017-04-22 08:58:54
0
6
916

這幾天看NoSQL,還是不太理解從傳統(tǒng)的關系型數(shù)據(jù)庫中的表、行、列轉(zhuǎn)換到NoSQL。

比如一個最簡單的博客數(shù)據(jù)庫設計,有分類表,有文章表、每個分類對應N條文章。

這樣的傳統(tǒng)關系數(shù)據(jù)庫設計怎么轉(zhuǎn)變到Mongodb、Redis呢?

巴扎黑
巴扎黑

reply all(6)
PHPzhong

Having used Mongodb, I designed it like this, for the article:

  • Title
  • Publish time
  • ...
  • Category
  • Tags (using array type)

Query articles by tags and categories, you can use aggregation Map/Reduce, etc.

For Redis, processing these is mainly implemented in your own application.

Ty80

Just use files for blogs. Put them in folders by date and name the folders with dates. Tags also use folders, and put softlinks of article files in them

迷茫

SQL name | MongoDB name

database | database
table | collection
row | document/BSON document
column | field
index | index
table | joins
primary key | primary key


Example: Create a table

Use SQL statements

CREATE TABLE users (
    id MEDIUMINT NOT NULL
        AUTO_INCREMENT,
    user_id Varchar(30),
    age Number,
    status char(1),
    PRIMARY KEY (id)
)

Use NoSQL statements

db.users.insert( {
    user_id: "abc123",
    age: 55,
    status: "A"
 } )
Ty80

You can completely use the idea of ????relational database to design the database, such as:

category collection:

name:string 

posts collection:

category_id: object_id
title:string 

You can also nest sub-documents, there are many posts doc under category collection

category:

posts: []
PHPzhong

To use NoSQL database, you must first abandon the idea of ??relational database. Use an object-based approach to handle data structures. Each NoSQL database represents a different design idea for object processing. This problem is too big. To learn NoSQL, forget about relational databases first.

PHPzhong

Many people have answered, but I haven’t seen a more comprehensive answer

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template