DBMS vs NOSQL

NOSQLDB categories

key / value pairs, sharded arrays, and document-oriented
approaches)

google App data stores. Its syntax in Python is simple and clear, and it was specifically
created to be easy to use and reminiscent of relational databases, while only providing the
services typical of key/value stores base on a massively scalable cloud computing service.


NOSQL DB benefits

the benefits of various non-relational approaches will be explained
in depth, in terms of simplicity (fewer services lead to less complexity), scalability
(weaker integrity assumptions lead to more dimensions of concurrency), and raw
performance (fewer features means fewer layers to pass through).


SQL vs NOSQL

Example,










How google App data engine do?

definition

class Position(db.Model):
job_title = db.StringProperty(multiline=False)
open_date = db.DateTimeProperty(auto_now_add=False)
close_date = db.DateTimeProperty(auto_now_add=False)
salary = db.StringProperty(multiline=False)
description = db.StringProperty(multiline=True)
...
class Applicant(db.Model):
position = db.ReferenceProperty(Position)
name = db.StringProperty(multiline=False)
birth_date = db.DateTimeProperty(auto_now_add=False)
address = db.StringProperty(multiline=False)
source = db.StringProperty(multiline=False,
choices=set(["employee referral", "recruiter", "advertisement"]))
applied_date = db.DateTimeProperty(auto_now_add=True)
...
Note that, position_id, application_id is generated by system.

Insertion

pos = Position()
pos.job_title = "Accountant"
pos.put()
app = Applicant()
app.position = pos.key()
app.name = "Homer Simpson"
app.put()


A inner join operation

For RDBMS,  a select operation is enough.

     SELECT P.job_title, A.name, A.birth_date, ...
FROM
Position P
INNER JOIN Applicant A
ON A.position_id = P.position_id
WHERE
P.salary > 100000
AND A.state = 'New Jersey'
ORDER BY
A.name


FLOW:  finding relevant job postings on disk and caching them in memory, writing new applicant records to disk, merging the information about positions and applicants in memory, filtering the results by Boolean expressions, sorting the results, etc.

How google app engine do?

positions = Position.all()
positions.filter("open_date <", date.now).filter("close_date >", date.now)
for position in positions:
# display the position in the list ...
applicants = Applicant.all()
applicants.filter("state =", "New Jersey")
for applicant in applicants:
position = applicant.Position()
# show data containing attributes of both position and applicant objects


It should be clear by this point that there is some (potentially large) class of
operations that we can achieve declaratively, with no effort, in a SQL database, which
require significant programming in a non-relational database.


However, the other properties of the data access may shift the balance of this
equation; when the task is not to produce a quick report, but instead to manage
this information for millions of users, in order to produce intermediate structures
that can answer search queries in fractions of a  millisecond, the prospect of
writing your own access code in this manner (via, for example, a map/reduce
operation) becomes much more attractive.


Advantages to using non-relational databases

•   Semi-Structured Data
•   Alternative Model Paradigms
•   Multi-valued properties
•   Generalized Analytics
•   Version History
•   Predictable Scalability
•   Schema Evolution

Advantages to using RDBMS databases

•   Ease of expression - writing queries is fast and easy, assuming those requirements
are within the purview of what SQL can do natively.
•   Concurrency and Transactions - ACID properties
•   Eventual Consistency
•   Normalized Updates and relational integrity
•   Standardization
•   Access Control

猜你喜欢

转载自wanhuir.iteye.com/blog/1441204