Graph plugin for databases
Many companies view graphs as an abstraction rather than an
implementation of the underlying database. There are two reasons for this :
1)
Key-value stores suffice to capture the same
information in a graph and can provide flexibility and speed for operations
that can be translated as queries on these stores. Then these can be
specialized for the top graph features that an application needs
2)
Different organizations within the company
require different stacks built on the same logical data for reasons such as
business impact, modular design and ease of maintenance.
Even large companies such as Twitter and Facebook don’t
necessarily use graph databases for their social network data. They use graph
database concepts but their implementations are usually highly specialized and
optimized REDIS, MySQL or such other databases.
These companies use a graph query layer that enables them to
do things such as graph traversals which are often needed in graph operations
but they execute against traditional Relational database management systems.
This abstraction is facilitated by a Resource Description
Framework data model which is intrinsically a labeled, directed multi-graph.
This kind of modeling is similar to classical data modeling and it makes
statements about resources in the form of subject-predicate-object expressions.
The subject denotes the resource, and the predicate denotes traits or
relationships between the subject and the objects. These expressions are known
as triples in RDF terminology and can even be persisted in relational database.
Plugins for conventional relational databases exploit RDF
and other data models such as Network data models or a collection of spatial
features in their offerings for supporting graph layer as an overlay. A network
data model is a property graph model used to model and analyze physical and
logical networks. A geospatial feature consists of a geometric representation
of the data in some co-ordinate space.
Many companies embrace key value stores over relational data
saying that relational data does not scale to arbitrary size without
performance degradation. This is not necessarily the fault of the relational
database but seems to be from its usage. In fact, large databases of relational
data can support recursive queries allowing native and direct translation of
graph operations.
Oracle did a major study on its spatial and graph plugin for
both relational and NoSQL data. In its approach, it consolidated several data
sources or data types such as medical devices, lab information systems,
subscription services and legacy records from different data servers such as
Lab/Clinical, Research, Content Management, Billings/Claims and Reporting/BI
into a central domain vocabulary. This central repository was none other than
an integrated graph metadata that was implemented as an RDF Triple Store. They
showed that it was scalable to billions of triples with RAC and exadata
scalability.
Courtesy : Oracle studies
#codingexercise
Find a subarray with sum k in a list of positive integers
Void sum(list<int> num, int k, ref list<int> candidate, int start)
{
If (candidate.sum() == k) { console.write(candidate.toString()); return;}
If (candidate.sum() > k) return;
If (start == num.count) return;
// with
Candidate.add(num[start]);
Sum(num, k, ref candidate, start+1);
Candidate.removeLast();
// without
Sum(num, k, ref candidate, start +1);
}
Another method to find contiguous sum is as follows:
int GetSumK(List<int>num, int k)
{
if (num.count == 0) return 0;
int curr = num[0];
int start = 0;
for (int i = 1; i <= num.count; i++)
{
while (cur > K && start < i-1)
{
curr = curr - num[start];
start++;
}
if (cur == K)
{
console.write("sum k between {0} and {1}", start, i-1);
return 1;
}
if (i < n)
curr = curr + num[i];
}
return 0;
}
Courtesy : Oracle studies
#codingexercise
Find a subarray with sum k in a list of positive integers
Void sum(list<int> num, int k, ref list<int> candidate, int start)
{
If (candidate.sum() == k) { console.write(candidate.toString()); return;}
If (candidate.sum() > k) return;
If (start == num.count) return;
// with
Candidate.add(num[start]);
Sum(num, k, ref candidate, start+1);
Candidate.removeLast();
// without
Sum(num, k, ref candidate, start +1);
}
Another method to find contiguous sum is as follows:
int GetSumK(List<int>num, int k)
{
if (num.count == 0) return 0;
int curr = num[0];
int start = 0;
for (int i = 1; i <= num.count; i++)
{
while (cur > K && start < i-1)
{
curr = curr - num[start];
start++;
}
if (cur == K)
{
console.write("sum k between {0} and {1}", start, i-1);
return 1;
}
if (i < n)
curr = curr + num[i];
}
return 0;
}
No comments:
Post a Comment