0% found this document useful (0 votes)
15 views89 pages

Understanding NoSQL Databases and Architecture

BDA SEM 7 PPT MODULE 3 NO SQL
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views89 pages

Understanding NoSQL Databases and Architecture

BDA SEM 7 PPT MODULE 3 NO SQL
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MODULE 3.

NoSQL
Contents
3

◻ Introduction
◻ Business drivers
◻ NoSQL Data Architecture Pattern
Key-Value Store
Graph Store
Column Family store
Document Store
◻ NoSQL solution for Big Data
4
What is RDBMS
2

❑ RDBMS:the relational database


management system.

❑ Relation: a relation is a 2D table


which has the following features:
▪ Name

▪ Attributes

▪ Tuples Name
5
Issues with RDBMS- Scalability
3

❑ Fixed table schemas


❑ Small but frequent reads/writes
❑ Can not work on commodity
hardware
❑ Issues with scaling up when the
dataset is just too big e.g. Big
Data.
❑ Not designed to be distributed.
6
Issues with RDBMS- Scalability
3
❑ Focus on ACID
❑ Atomicity
❑ Consistency
❑ Isolation
❑ Durability
❑ ACID is important, but only when it’s important
❑ i.e. banking, finance, safety systems, etc.
❑ The kinds of systems that people were building with computers 30 years
ago (and today)
❑ ACID adds overhead
❑ Features like atomicity, isolation basically force database servers to use
sequential evaluation
7
What is
5

NoSQL
◻Stands for Not Only SQL.
◻ “NoSQL is a set of concepts that allows the rapid and
efficient processing of datasets with a focus on
scalability, performance, reliability, and agility. “
❑ Provide mechanism for storage and retrieval of
unstructured data in distributed environment.
❑ Work for unpredictable dynamic data
❑ Developed to handle large amount of data that need to be
frequently accessed and processed.
2/5 marks

8
Need of
6

NoSQL
▪ Explosion of social media sites (Facebook, Twitter, Google etc.) with large data
needs.
▪ The system response time becomes slow when you use RDBMS for massive
volumes of data.
▪ Solution:
▪ "scale up" our systems by upgrading our existing hardware. This process is
expensive.
▪ "scaling out" is to
distribute database
load on multiple hosts
whenever the load
increases.
4 Marks

CAP Theorem
9

◻ Consistency –
All the servers in the system will have the same data so
anyone using the system will get the same copy
regardless of which server answers their request.
◻ Availability –
The system will always respond to a request (even if it's
not the latest data or consistent across the system or just
a message saying the system isn't working)
◻ Partition Tolerance –
The system continues to operate as a whole even if
individual servers fail or can't be reached..
10 Marks

What are the characteristics/ features?


10

◻ It’s more than rows in tables


NoSQL systems store and retrieve data from many formats: key-value stores, graph databases,
column-family (Bigtable) stores, document stores, and even rows in tables.
◻ It’s free of joins
NoSQL systems allow you to extract your data using simple interfaces without joins.
◻ It’s schema-free
NoSQL systems allow you to drag-and-drop your data into a folder and then query it without
creating an entity-relational model.
◻ It works on many processors
NoSQL systems allow you to store your database on multiple processors and maintain
high-speed performance.
Contd.. characteristics/ features
11

◻ It uses shared-nothing commodity computers


Most (but not all) NoSQL systems leverage low-cost commodity
processors that have separate RAM and disk.
◻ It supports linear scalability
When you add more processors, you get a consistent increase in
performance.
10 marks

Difference between RDBMS and NoSQL


12

Sr. No RDBMS NoSQL


1 Have fixed or static predefined schema Have dynamic Schema
2 Vertically scalable Horizontally scalable
3 Table based databases Document based, key-value pairs, graph
databases or wide-column stores.
4 SQL ( structured query language ) for defining and Uses unstructured Query Language
manipulating the data
5 SQL databases maintains on ACID properties ( NoSQL database follows the Brewers CAP
Atomicity, Consistency, Isolation and Durability) theorem.

6 Synchronous Inserts & Updates Asynchronous Inserts & Updates


7 Standard interface for executing complex query Support only simple transactions
8 Have single point of failure Have no single point of failure
9 Transactions written in one location Transactions written in many locations.
10 Eg.: Oracle, MS-SQL,MySQL Eg: MongoDB, BigTable, Cassandra, Hbase,Neo4j,
CouchDB etc
NoSQL Business Drivers:
13

◻ 1. Scalability
◻ 2. Big Data & Real-Time Analytics
◻ 3. Flexible Data Models
◻ 4. High Availability & Global Distribution
◻ 5. Support for Modern Applications
◻ 6. Cost Efficiency
◻ 7. Cloud & Micro services Architecture
NoSQL Business Drivers:

14

1. Scalability
Businesses with rapidly growing data volumes require systems that can handle
more data and more users without performance degradation.

NoSQL advantage:

○ Horizontal scaling (adding more servers) instead of vertical scaling


(buying bigger servers).

○ Examples: Facebook, Amazon, Netflix store petabytes of data across


many commodity servers.
15

2. Big Data & Real-Time Analytics


Companies want insights from huge, varied, and fast-arriving data streams.
NoSQL advantage:

○ Optimized for high-volume, high-velocity data.

○ Can handle structured, semi-structured, and unstructured data.

○ Examples: Log analytics, IoT sensor data.

3. Flexible Data Models

Businesses evolve quickly; schema changes in relational databases are costly and time-consuming.

● NoSQL advantage:

○ Schema-less or flexible schema design (JSON, key-value, column-family, graph).

○ Easy to add new attributes without downtime.


16

4. High Availability & Global Distribution

Applications must be available 24×7 worldwide.


NoSQL advantage:

○ Built-in replication across data centers and geographies.

○ Fault tolerance by design.

5. Support for Modern Applications

Mobile apps, social networks, gaming platforms, IoT solutions require speed, scalability, and flexible data handling.

● NoSQL advantage:

○ Low latency reads/writes.

○ Handles semi-structured formats (JSON, XML).


17

6. Cost Efficiency

Minimize infrastructure and licensing costs while scaling.

● NoSQL advantage:

○ Runs on commodity hardware.

○ Many NoSQL databases are open source (MongoDB, Cassandra, Redis).

7. Cloud & Micro services Architecture

Agile, distributed, loosely coupled services.

● NoSQL advantage:

○ Works naturally with cloud-native deployments and containerized applications.

○ Decentralized architecture fits micro services patterns.


10 marks

18
NoSQL Data Architecture Pattern
7

NoSQL database are classified into four types:


•Key Value pair based
• Document based
• Column based
• Graph based
19 Key-Value Store
✔ What a key-value store is
✔ Benefits of using a key-value
store
✔ How to use a key-value store in
an application
✔ Key-value store use cases
Key-value stores
20

• A key-value store is a simple database that when


presented with a simple string (the key) returns
an arbitrary large BLOB of data (the value).
• A key-value store is like a dictionary.
• Word entries represent keys and definitions
represent values.
• Entries are sorted alphabetically by word, retrieval is
quick.
• A key-value store is also indexed by the key.
• The key points directly to the value, resulting in
rapid retrieval, regardless of the number of
items in your store.
Key-value stores (Cont.)
21

❑ No need to specify a data type for the value of a key-value


store
o So you can store any data type that you want in the
value.
o Each value can have different number of attributes
❑ The system will store the information as a BLOB and return
the same BLOB when a GET (retrieval) request is made.
o The value can :
✔ images,
✔ web pages,
✔ Documents
✔ videos.
Key-value stores (Cont.)
22

◻ Example:
Value

Key
Key-value stores (Cont.)
23

The key in a key-value store is flexible and can be represented by many


formats:
• Logical path names to images or files
• Artificially generated strings created from a hash of the value
• REST web service (Representational State Transfer — it’s an architectural style for designing
networked applications, especially web services)
• SQL queries
Using a key-value store
24

• The best way to think about using a key-value store is to visualize a


single table with two columns.
• There are three operations performed on a key-value store:
• put
• get
• delete
Using a key-value store
25

• put($key as xs:string, $value as item()) adds a new key-value pair


to the table and will update a value if this key is already present.
• get($key as xs:string) as item() returns the value for any given key, or
it may return an error message if there’s no key in the key-value store.
• delete($key as xs:string) removes a key and its value from the table, or
it many return an error message if there’s no key in the key-value store.
Key-value store rules
26

A key-value store has two rules:


• Distinct keys: if you can’t uniquely identify a key-value pair, you can’t return a single
result.
• No queries on values: In a relational database, you can constrain a result set using the
where clause. key-value store prohibits this type of operation, as you can’t select a
key-value pair using the value.
Restrictions of Keys and Values
A key:
▪ as long as it’s a reasonably short string of characters.
The value of a key-value store.:
▪ As long as your storage system can hold it
▪ Making structure ideal for multimedia: images, sounds, and even full-length
movies.
Use cases
27

• Use case: Storing web pages in a key-value


store

• Use case: Amazon simple storage service (S3)


Use cases
28

◻ Storing web pages in a key-value store


? A web crawler to automatically visit a website to extract and store the content of each web page
? The words in each web page are then indexed for fast keyword search.
? The URL is the key, and the value is the web page or resource located at that key.
? Dynamic portions of a site where pages are generated by scripts are not stored in the key-value
store
Use cases
29

◻ Amazon simple storage service (S3)


? S3 is a simple key-value store with some enhanced features:
■ It allows an owner to attach metadata tags to an object, to provides additional information
about the object;
■ For example, content type, content length, cache control, and object expiration.
■ It has an access control module to allow a object owner
■ to grant rights to individuals, groups, or everyone to perform
■ put, get, and delete operations on an object, group of objects, or bucket.
Use cases
30

◻ Amazon simple storage service (S3)


? At the heart of S3 is the bucket
? All objects you store in bucket
? Buckets store key/object pairs,
■ The key: is a string (unique within a bucket)
■ The object: images, XML files, digital music.
Use cases
31

◻ Amazon simple storage service (S3)


? To manipulate objects:

■ HTTP PUT message : New objects are added to a bucket.


■ HTTP GET message :Objects are retrieved from a bucket.
■ HTTP DELETE message: Objects are removed from a bucket
? To access an object

■ Generate a URL from the bucket/key combination


■ Example:
■ [Link]
Bucket name Object Key
32 Document Store
✔ Introduction
✔ Document collections
✔ Document store implementations
✔ Case study
Document Oriented Database
33

◻ It is similar to key-value database


◻ But Document database contains structure or semi structure data.
? Structure or semi structure data value is referred as document.

◻ The key-value store lack a formal structure and


aren’t indexed or searchable.
? Return the value (a BLOB of data) associated with that key
Document Oriented Database
34
Document Oriented Database
35

◻ Documents are gathered together in collections within the database


? Eg:- Book collection, Video collection, web page collection, etc.
Document Store
36

▪ Properties:
▪ Key may be a simple ID which is never used or seen
▪ Can query any value or content within the document
▪ Everything inside a document is automatically indexed when a new document is
added.

SID Name Phone


{
16s143 Sagar 9723486 {
_id: 16s143,
_id: 16s144,
16s144 Nikita 9723456 Name: Sagar,
Name: Nikita,
Phone: 9723486
Phone: 9723456
}
}
What is a Document
37

DB?
{ {
"name": "Phil", "age": 26,
"name": "Phil",
"status": "A",
"age": 26,
"citiesVisited" : ["Chicago", "LA", "San Francisco"]
"status": "A"
} }
❑ Documents can have differences in their attributes
❑ But belongs to the same collection
❑ A document can be
❑ PDF
❑ Microsoft word doc
❑ XML
❑ JSON file.
Document Store….eg.
38
Document Store
39

• Document stores can tell not only that your search item is in the
document, but also the search item’s exact location by using the
document path, a type of key, to access the leaf values of a tree
structure.
Document Store Basics
40

• Think of a document store as a tree-like structure


• Beneath the root element there is a sequence of branches
• Each branch has a related path expression that shows you how to
navigate from the root of the tree to any given branch, sub-branch,
or value.
Document collections
41

❑ Most document stores group documents together in collections


❑ Document collections can be used in many ways to manage large
document stores.
▪ They can serve as ways to navigate document hierarchies
▪ Logically group similar documents
▪ Store business rules such as permissions, indexes, and triggers.
❑ Collections can contain other collections and trees can contain subtrees.
▪ Collections to have collections.
Document collections
42
Document store implementations
43

• A document store can come in many varieties.


• Simpler document structures are often associated with serialized
objects and may use the JavaScript Object Notation (JSON) format.
Document Oriented Databases
44

◻ Examples:
? MongoDB
? CouchDB
? DocumentDB
45
Use Case:An e-commerce platform (like Amazon, Flipkart, eBay) sells:

46

◻ Millions of products.
◻ Products from different categories — electronics, clothing, furniture,
groceries, etc.
◻ Each category has different attributes:
A shirt → size, color, fabric.
A laptop → CPU, RAM, storage, battery life.
A book → author, ISBN, publication year.
◻ With a relational database, you’d need:
◻ Separate tables for each category, or
◻ A huge table with many NULL columns for irrelevant attributes.
◻ Schema changes whenever a new product type is introduced.
47

◻ MongoDB’s document model lets each product store only the


attributes it needs, without impacting others.
◻ Advantages:
◻ Flexible Schema: Add new fields without database migration.
◻ Embedded Documents: Store product details, reviews, pricing, and
inventory together.
◻ Indexing: Fast search by product name, category, attributes.
◻ Scalability: Handle large catalogs across multiple servers.
48
Query
49

Find laptops with at least 16GB


•Find all blue shirts: RAM
◻ [Link]({
category: "Clothing", [Link]({
◻ "[Link]": "Blue" category: "Electronics",
◻ }) "[Link]": { $gte: "16GB" }
})
50
Case study: ad server with MongoDB
51

• MongoDB, a popular NoSQL product, was to create a


service that would quickly send a banner ad to an area
on a web page for millions of users at the same time.
• The primary purpose behind ad service:
• quickly select the most appropriate ad for a user and place it on the page in the time it takes a web page to load
Case study: ad server with MongoDB
52

• Complex business rules followed:


• Ad servers should be highly available and run 24/7 with no downtime
• To find the most appropriate ad to send to a web page.
• Ads are selected from a database of ad promotions of paid advertisers
that best match the person’s interest.
• Ad servers can’t send the same ad repeatedly
• Able to send ads of a specific type (page area, animation, and so
on) in a specific order.
• Finally, ad systems need accurate reporting that shows what ads
were sent to which user and which ads the user found interesting
enough to click on.
Case study: MongoDB (Cont.)
53

MongoDB can be used in some of the following use cases:


• Content management :- Store web content and photos and use tools such as
geolocation indexes to find items.
• Real-time operational intelligence :-Ad targeting, real-time sentiment analysis,
customized customer-facing dashboards, and social media monitoring.
• Product data management :-Store and query complex and highly variable
product data.
• User data management :-Store and query user-specific data on highly scalable
web applications. Used by video games and social network applications.
• High-volume data feeds :-Store large amounts of real-time data into a central
database for analysis characterized by asynchronous writes to RAM.
54
Column family (Bigtable)
Overview

stores Column family basics

✔ Understanding column family


keys
✔ Benefits of column family
systems
✔ Case study
Data stores
55

Key / value stores (opaque / typed) Document stores (non-shaped / shaped)


collection
key value
valu
e key document
valu
key value e
key document
... Relational databases
table ...
row
key

column
column
valu
row
e
key
Relational databases
56

❑ Tables (relations) consist of rows and columns


❑ Columns have a type. Type information is stored once per column.
A rows contains just values for a record (no type information)
❑ All rows in a table have the same columns and are homogenous

table
column typ column type column type column typ column type
row e e
key value value value value value

row
Example rows: key value value value value value
„foo“, „bar“, 25, 35.63
„bar“, „baz“, 42, -673.342
Row vs. columnar relational databases
57

 All relational databases deal with tables, rows, and


columns
 But there are sub-types:
 Row-oriented: they are internally organised around the handling
of rows
 Columnar / column-oriented: these mainly work with columns
 Both types usually offer SQL interfaces and produce
tables (with rows and columns) as their result sets
 Both types can generally solve the same queries
Row-oriented storage
58


In row-oriented databases, row value data is usually
stored contiguously:

row0 header column0 value column1 value column2 value column3 value
row1 header column0 value column1 value column2 value column3 value
row2 header column0 value column1 value column2 value column3 value

(the row headers contain record lengths, NULL bits etc.)


Row-oriented storage
59

Rows stored sequentially


Key Fname Lname State Zip Phone Age Sex
1 Bugs Bunny NY 11217 (718) 938-3235 34 M
2 Yosemite Sam CA 95389 (209) 375-6572 52 M
3 Daffy Duck NY 10013 (212) 227-1810 35 M
4 Elmer Fudd ME 04578 (207) 882-7323 43 M
5 Witch Hazel MA 01970 (978) 744-0991 57 F

✔ Best performance when most queries are for multiple


columns of a single row
Key Lookup in a Row-Oriented Database
60

Indexes
Key RowID Indexes on high-cardinality columns
1 0001B008D23A671A
2 0001B008D23A671B make accessing a single row very fast
3 0001B008D23A671C
Key Fname Lname State Zip Phone Age Sex
4 0001B008D23A671D
1 Bugs Bunny NY 11217 (718) 938-3235 34 M
5 0001B008D23A671E
2 Yosemite Sam CA 95389 (209) 375-6572 52 M ABC calls
3 Daffy Duck NY 10013 (212) 227-1810 35 M customer service
4 Elmer Fudd ME 04578 (207) 882-7323 43 M
WHERE key=4 5 Witch Hazel MA 01970 (978) 744-0991 57 F

but don’t help on analytical queries which


Phone RowID scan many rows
(207) 882-7323 0001B008D23A671D
(209) 375-6572 0001B008D23A671B
(212) 227-1810 0001B008D23A671C
(718) 938-3235 0001B008D23A671A e.g.
(978) 744-0991 0001B008D23A671E
What’s the average age of males?
WHERE phone=‘(207) 882-7323’
Column-oriented storage
61

 Column stores store data in column-specific files


 Simplest case: one datafile per column
 Row values for each column are stored contiguously

column0 values
column0
r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17

filesize

column1 values
column1
r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17

filesize
Column-Oriented Storage
62

Each column is stored in a separate file

Key Fname Lname State Zip Phone Age Sex


1 Bugs Bunny NY 11217 (718) 938-3235 34 M
2 Yosemite Sam CA 95389 (209) 375-6572 52 M
3 Daffy Duck NY 10013 (212) 227-1810 35 M
4 Elmer Fudd ME 04578 (207) 882-7323 43 M
5 Witch Hazel MA 01970 (978) 744-0991 57 F

Each column for a given row is at the same offset (auto-indexing)


Column-oriented storage
63

 Column stores can greatly improve the performance of queries that only
touch a small amount of columns
 This is because they will only access these columns' particular data
 Simple math: table t has a total of 10 GB data, with
 column a: 4 GB
 column b: 2 GB
 column c: 3 GB
 column d: 1 GB
 If a query only uses column d, at most 1 GB of data will be processed by a
column store
 In a row store, the full 10 GB will be processed
Column family
64

◻ Column family Vs Column Oriented


? A column-family database stores a row with all its column
families together
? A column-oriented database simply stores data tables by
column rather than by row.

▪ Use concept of keyspace (like a schema in the


relational model)
▪ The keyspace contains all the column families (kind
of like tables in the relational model), which
contain rows and columns.
Example of Column family
65

◻ Each rows
contains different
number of
columns
Benefits of Column Family Systems
66

✔ Higher Scalability
✔ Higher Availability
✔ Easy to Update
Benefits of Column Family Systems ….Higher
67
Scalability
❑ Bigtable-inspired column family systems are designed to scale
beyond a single processor.
❑ As you add more data to your system, your investment will be in
the new nodes added to the computing cluster.
❑ By keeping the interface simple, the back-end system can
distribute queries over a large number of processing nodes
without performing any join operations.
❑ With careful design of row IDs and columns, the system get
enough hints to tell where to get related data and avoid
unnecessary network traffic crucial to system performance.
Benefits of Column Family Systems …. Higher
68
Availability
❑ By building a system that scales on distributed networks,
gain the ability to replicate data on multiple nodes in a
network.
❑ Due to efficient communication, the cost of replication is
lower.
❑ Due to lack of join operations allows you to store any
portion of a column family matrix on remote computers.
Benefits of Column Family Systems …. Easy to
69
Add New Data
❑ A key feature of the column family store is that you don’t need to fully
design data model before inserting data.

❑ Rules :
• Your groupings of column families should be known in advance.
• Row IDs and column names can be created at any time.
Benefits of Column Family Systems …. Easy to
70
Add New Data
❑ Row-oriented: Usually requires rebuilding table

Key Fname Lname State Zip Phone Age Sex Golf Addition of
1 Bugs Bunny NY 11217 (718) 938-3235 34 M Y
2 Yosemite Sam CA 95389 (209) 375-6572 52 M N column shifts
3 Daffy Duck NY 10013 (212) 227-1810 35 M Y
4 Elmer Fudd ME 04578 (207) 882-7323 43 M Y every row
5 Witch Hazel MA 01970 (978) 744-0991 57 F N

❑ Column-oriented: Just create another file


Key Fname Lname State Zip Phone Age Sex Golf
1 Bugs Bunny NY 11217 (718) 938-3235 34 M Y
2 Yosemite Sam CA 95389 (209) 375-6572 52 N
M
3 Daffy Duck NY 10013 (212) 227-1810 35 Y
4 Elmer Fudd ME 04578 (207) 882-7323 43 M Y
5 Witch Hazel MA 01970 (978) 744-0991 57 M N
F

70
Benefits of Column Family Systems …. Easy to
71
Update
Row-oriented: value replaced
Key Fname Lname State Zip Phone Age Sex
1 Bugs Bunny NY 11217 (718) 852-2352 34 M
2 Yosemite Sam CA 95389 (209) 375-6572 52 M
3 Daffy Duck NY 10013 (212) 227-1810 35 M
4 Elmer Fudd ME 04578 (207) 882-7323 43 M
5 Witch Hazel MA 01970 (978) 744-0991 57 F

Column-oriented: value replaced


Key Fname Lname State Zip Phone Age Sex
1 Bugs Bunny NY 11217 (718) 852-2352 34 M
2 Yosemite Sam CA 95389 (209) 375-6572 52 M
3 Daffy Duck NY 10013 (212) 227-1810 35 M
4 Elmer Fudd ME 04578 (207) 882-7323 43 M
5 Witch Hazel MA 01970 (978) 744-0991 57 F

Yeah, this one just works.


Column family Limitations
72

◻ Work on distributed clusters of computers.


◻ May not be appropriate for small datasets.
◻ Need at least five processors to justify a column family cluster.
? To store data on three different nodes for replication.

◻ Don’t support standard SQL queries for real-time data access.


Case study: Storing analytical information in
Bigtable
73

❑ The Bigtable is used to store website


usage information in Google Analytics.
❑ The Google Analytics service allows you
to track who’s visiting your website.

❑ Viewing a detailed log of all the individual hits on your site


would be a long process.

❑ Google Analytics makes it simple by summarizing the data


at regular intervals (such as once a day) and creating
reports that allow you to see the total number of visits and
most popular pages that were requested on any given day.
74
75
76
Graph Store
✔ Overview
✔ Linking
external data
✔ Use cases
Overview
77

❑ A graph store is a system that contains a sequence of nodes and


relationships that, when combined, create a graph.
❑ A graph store has three data fields:
▪ Nodes,
▪ Relationships,
▪ Properties.

❑ Graph stores are ideal when you have many items that are related to each other in
complex ways and these relationships have properties.
Overview (Cont.)
78

❑ Graph nodes are usually representations of real-world objects like nouns.


• People, organizations, telephone numbers, web pages, computers on a
network, or even biological cells in a living organism.
❑ The relationships is connections between these objects
▪ Represented as arcs (lines that connect) between circles in diagrams.
Overview (Cont.)
79

❑ Graph queries are similar to traversing nodes in a graph:


o What’s the shortest path between two nodes in a graph?
o What nodes have neighboring nodes that have specific properties?
o Given any two nodes in a graph, how similar are their neighboring
nodes?
o What’s the association of various points on a graph with each
other?
Graph Stores
80

❑ Graph stores are difficult to scale out on multiple servers


due to the close connectedness of each node in a graph.
▪ Data can be replicated on multiple servers to enhance read
and query performance
▪ But writes to multiple servers and graph queries that span
multiple nodes can be complex to implement.
❑ Interaction methods : load, query, update, and delete
▪ A graph query will return a set of nodes that are used to
create a graph image on the screen to show you the
relationship between your data.
A Graph Example
81

❑ You’ll often see links on a page that take you to another page.
❑ These links can be represented by a graph or triple.
o The current web page is the first or source node Property: URL
o The link is the arc that “points to” the second page
o The second or destination page is the second node Source
web page

o”

“Poi
Source web page Destination web page

tt
oin

nt to
“P


Destination
web page Destination
web page
Property: URL
Property: URL
82
Linking external data

Statement is :(Book, has-author,


Person123)
Statement is: (Person123, has-name, “Dan”).

❑ When stored in a graph store, the two statements are independent and
may even be stored on different systems around the world.
Link metadata
✔ Group ID the graph belongs to
✔ The date and time the node was
created or last updated
Use cases for graph stores
83

❑ Link analysis is used when you want to perform searches and look for
patterns and relationships in situations such as social networking,
telephone, or email records.

❑ Rules and inference are used when you want to run queries on
complex structures such as class libraries, taxonomies and rule-based
systems.

❑ Integrating linked data is used with large amounts of open linked data
to do realtime integration and build mashups without storing data.
Link analysis
84

❑ Sometimes the best way to solve a business problem is to traverse


graph data.
❑ As you add new contacts to your friends list, you might want to know if
you have any mutual friends.
▪ need to get a list of your friends, and for each one of them get a list
of their friends (friends-of-friends).
❑ Relational database :After the initial pass of listing out your
friends, the system performance drops dramatically!!!
Link analysis (Cont.)
85

• Graph stores can perform these operations much faster by using techniques
that consolidate and remove unwanted nodes from memory.
• Though graph stores would clearly be much faster for link analysis tasks, they
usually require enough RAM to store all the links during analysis.

A social network graph generated by


the LinkedIn InMap system. Each
person is represented by a circle, and
a line is drawn between two people
that have a relationship
Rules and inference
86

❑ Rules:
❑ That relate to an understanding of objects in a system, and how the
object properties allow you to gain insight into and better use large
datasets.
❑ An inference:
❑ discover other facts about a system
Rules and inference
87

Suppose you have a website that allows anyone to


post restaurant reviews.
❑ Would there be value in allowing you to indicate which
reviewers you trust?
❑ You’re going out to dinner and you’re considering two
restaurants. Each restaurant has positive and negative reviews.
❑ Can you use simple inference to help you decide which
restaurant to visit?
❑ You could see if your friends reviewed the restaurants. But a more powerful test
would be to see if any of your friends-of-friends also reviewed the restaurants.
❑ If you trust John and John trusts Sue,what can you infer about your ability to trust
Sue’s restaurant recommendations?
88
NoSQL Database Types
89

You might also like