NOSQL中的Key_value模型

前端之家收集整理的这篇文章主要介绍了NOSQL中的Key_value模型前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Are you familiar with the concept of a Key/Value Pair? Presuming you're familiar with Java or C# this is in the language as a map/hash/datatable/KeyValuePair (the last is in the case of C#)

The way it works is demonstrated in this little sample chart:

Color Red Age 18 Size Large Name Smith Title The Brown Dog

Where you have a key (left) and a value (right) ... notice it can be a string,int,or the like. Most KVP objects allow you to store any object on the right,because it's just a value.

Since you'll always have a unique key for a particular object that you want to return,you can just query the database for that unique key and get the results back from whichever node has the object (this is why it's good for distributed systems,since there's other things involved like polling for the first n nodes to return a value that match other nodes returns).

Now my example above is very simple,so here's a slightly better version of the KVP

user1923_color Red user1923_age 18 user3371_color Blue user4344_color Brackish user1923_height 6' 0" user3371_age 34

So as you can see the simple key generation is to put "user" the userunique number,an underscore and the object. Again,this is a simple variation,but I think we begin to understand that so long as we can define the part on the left and have it be consistently formatted,that we can pull out the value.

Notice that there's no restriction on the key value (ok,there can be some limitations,such as text-only) or on the value property (there may be a size restriction) but so far I've not had really complex systems. Let's try and go a little further:

app_setting_width 450 user1923_color Red user1923_age 18 user3371_color Blue user4344_color Brackish user1923_height 6' 0" user3371_age 34 error_msg_457 There is no file %1 here error_message_1 There is no user with %1 name 1923_name Jim user1923_name Jim Smith user1923_lname Smith Application_Installed true log_errors 1 install_path C:\Windows\System32\Restricted ServerName localhost test test test1 test test123 Brackish devonly wonderwoman value key

You get the idea... all those would be stored in one massive "table" on the distributed nodes (there's math behind it all) and you would just ask the distributed system for the value you need by name.

At the very least,that's my understanding of how it all works. I may have a few things wrong,but that's the basics.

原文链接:https://www.f2er.com/nosql/204397.html

猜你在找的NoSQL相关文章