Database

ArangoDB is a NoSQL database system and supports key/value,documents,graphs data models with AQL (ArangoDB Query Language) query language.

The database uses JSON as a default storage format and it can store a nested JSON object inside a collection,although they are stored in binary format called ‘VelocyPack‘.

In NoSQL tables are called as collections and there are two type of collections,

  1. Document collection
  2. Edge collection – it have _from and _to attributes,which are used to create relations between documents.

Queries are used to filter documents based on criteria and compute new data,as well as delete and manipulate data.Indexes are used to speed up searches,there are two major indexes,

  1. Hash Indexes –  if hash index is unique,then uniqueness is violated.
  2. Geo-spatial Indexes – it supports containment and intersection queries for various geometric

A REST API is provided to interact with the database system.

ArangoDB has web interface and interactive shell.web interface called as

‘Aardvark ‘ and an interactive shell called as ‘Arangosh’


Installation steps on centos 7:

Update OS to latest stable versions,

$ sudo yum update -y

For installation go to ArangoDB installation path,

cd /etc/yum.repos.d/

on that path,

curl -OL https://download.arangodb.com/arangodb34/RPM/arangodb.repo
$ sudo yum install arangodb3-3.4.0

To start ArangoDB server:

$ sudo systemctl enable arangodb3
$ sudo systemctl start arangodb3
$ sudo systemctl status arangodb3

To verify the installation ,

$ sudo arangosh 

Endpoint IP configuration:

vi /etc/arangodb3/arangod.conf

endpoint = tcp://<ip>:8529

the default port for ArangoDB server is 8529

IP config to enable web interface:

vi /etc/arangodb3/arangosh.conf (change ip on endpoint = tcp://<ip>:8529)

$ sudo systemctl restart arangodb3

To change root password,

$ sudo systemctl stop arangodb3

ARANGODB_DEFAULT_ROOT_PASSWORD=your_password arango-secure-installation

$sudo systemctl start arangodb3

Your installed server now available on http://<ip>:8529.

ArangoSearch Views:

ArangoSearch is a new search engine feature in 3.4 version.It allows,

  1. To join documents located in different collections
  2. Filter douments
  3. Sort the result set based on criteria

ArangoSearch view creation:

In server,type the command as arangosh

To create view,

v = db._createView("ExampleView ", "arangosearch", {});

To linking with created collection and adding indexing parameter

v = db._view("ExampleView");

 

v.properties({
        links: {
          /* collection Link 0 with additional custom configuration: */
          ExampleCollection0: {
            /* examine fields of all linked collections, using default configuration: */
            includeAllFields: true,
            fields: {
              /* a field to apply custom configuration that will index English text: */
              name: {
                analyzers: ["text_en"]
              },
              /* another field to apply custom configuration that will index Chinese text: */
              text: {
                analyzers: ["text_zh"]
              }
            }
          }
        }
      });

ArangoSearch view query sample:

db._query(`FOR doc IN ExampleView
  SEARCH PHRASE(doc.text, 'Active', 'text_zh') OR STARTS_WITH(doc.b, 'ba')
  SORT TFIDF(doc) DESC
  RETURN doc`);


Reference:

https://www.arangodb.com/docs/stable/index.html

 

0

Web Technologies

ECMAScript (ES) is a standardized scripting language for JavaScript (JS). The first edition of the ECMA Script was published in June 1997. The sixth version of ECMA Script6 is known as ES6 (it is also called as ECMA Script 2015). ES6 vs ES5 are two of the important scripting languages in the Software Development industry. Both ES5 vs ES6 have some similarities in nature but at the same time, there are also many difference between each other. Here, we will have discussion on ES6 vs ES5.

Exporting & Importing Modules

Exporting and importing module syntax changed introduction of ES6 specification.

Here is the exporting and Importing syntax,

var sampleModule= { x: 1, y: function(){ console.log('This is ES5') }}

// ES5 Export
module.exports =  sampleModule; 

// ES6 Export 
export default sampleModule; 

// ES5 Import
var sampleModule = require('./sampleModule'); 

// ES6 import
import sampleModule from './sampleModule';

Spread operator (…)

Spread Operator is introduced in ES6, merging the objects and arrays made easier by this.

Follows the spread operator usage/syntax,

var obj1 = { x: 1, y: 2 };
var obj2 = { c: 3, d: 4 };

// ES5
var obj3 = Object.assign(obj1, obj2);

// ES6
var obj3 = { ...obj1, ...obj2 };

Template Literal (`)

Template Literals are a new ES2015 / ES6 feature that allows you to work with strings. Template literals provide an easy way to interpolate variables and expressions into strings.
You do so by using the ${...} syntax.,

const myVariable = 'test'
const newVariable = `something ${myVariable}`;

Arrow Function (=>)

Arrow functions is also called as “fat arrow” functions. Arrow functions make our code more concise, simplify function scoping.

// ES5
var multiply = function(x, y) {
  return x * y;
};

// ES6
const multiply = (x, y) => { return x * y };

Promises and Callbacks

Javascript is an Async language we all know that. This feature gives developers to code freely, meanwhile all often contains a lots of function and return keywords. When using promises, these function expressions will be used for chaining. ES6 code is quite simplified.

// ES5
aAsync().then(function() {
  return bAsync();
}).then(function() {
  return cAsync();
}).done(function() {
  finish();
});

// ES6
aAsync().then(() => bAsync()).then(() => cAsync()).done(() => finish);

Performance and Support

With the help of newly implemented features and shorthand storage implementation, ES6 scores a higher performance rank than ES5, whereas ES5 has larger range of community supports than ES6.

0

Operating Systems
Linux volume management (LVM) creates an easy to use layer over physical disks. You can combine multiple disks and create logical storage volumes, the blog will explain you  how to create partition, formatting, and add the disk to LVM volume in CentOS Login to the server as root or sudo user
$ sudo fdisk -l
This will display the new added storage, for e.g /dev/vdb, type the below command to create physical volume
$ sudo pvcreate /dev/vdb
Add newly created physical volume /dev/vdb to an existing logical volume, in our case it root volume. To check the existing volumes you can use lvdisplay command
$ sudo vgextend centos /dev/vdb
Extend the /dev/centos/root to use the full available space
$ sudo lvm lvextend -l +100%FREE /dev/centos/root
To resize the disk size,
xfs_growfs /dev/mapper/centos-root
Verify the root volume space is extended by typing df -h
0

Database

NoSQL is not a relational database.


A relational database (RDBMS) stores a data in tabular form and that tables will have a primary key identifier. This is the predefined schema and MySQL, Oracle, PostgreSQL, Microsoft SQL Servers are examples of relational databases.


A non-relational database is a dynamic schema for unstructured data. Data can be stored in multiple collections and nodes. It is designed for distributed data stores where large scale of data storing needs. The evolution of NoSQL databases will handle huge amount of data easily. MongoDB, Redis, Cassandra are some of non-relational databases.


NoSQL is open-source, cheaper, faster and it offers for developing modern applications like Facebook, Google mail, LinkedIn. NoSQL is easily scalable, less expensive, lesser server cost, no fixed model, support integrated caching.


There are 4 basic types


Key-Value Store

It is a simple database which stores data without schema structure. Redis, Amazon S3, Amazon dynamo database are best examples of key-value store database.


Document databases

Some real-time applications are using document databases. MongoDB is one of the example of document database and it can handle any kind of data, structure and format. It provides some structure and encoding. Some encodings are JSON,XML,BJSON.


MongoDB is used for Aadhar and eBay applications. In Aadhar application, it is used to store images.


Column based databases

Datas are stored in column and that columns are grouped.


The benefits of storing datas in column enables fast search, fast access and data aggregation and also very efficient at data compression and partitioning. It provides high scalability.


Example: Cassandra


Graph Databases

Graph Databases are widely using social networking applications as it is perfect to address scalability. Data transfer from one model into another can be easy.


NoSQL follows CAP Theorem. That is ,


Consistency – Database remains consistent after execution of operation 
Availability – System is always on, there is no downtime Partition
Tolerance – No function break

A both SQL and NoSQL having their own places and being integrated into each other. NoSQL is best solution for rapid development, cloud-based storage and storing large volume of data.

0