Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

April 17, 2020

Part 6: Elastic Search Interview Questions And Answers(Hands On)

Explain Bool Query in ElasticSearch.
A query that matches documents matching boolean combinations of other queries is called Bool Query. It is built using one or more boolean clauses, each clause with a typed occurrence. 

  • must: The clause (query) must appear in matching documents and will contribute to the score.
  • filter: The clause (query) must appear in matching documents. However unlike must the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching.
  • should: The clause (query) should appear in the matching document.
  • must_not: The clause (query) must not appear in the matching documents. Clauses are executed in filter context meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned.

What is the difference between MUST and SHOULD bool query?
must means: The clause (query) must appear in matching documents. These clauses must match, like logical AND.
should means: At least one of these clauses must match, like logical OR.

In other words, results will have to be matched by all the queries present in the must clause or match at least one of the should clauses if there is no must clause.

What is the difference between MUST and FILTER bool query?
The must contributes to the score. In filter, the score of the query is ignored.

In both must and filter, the clause(query) must appear in matching documents. This is the reason for getting same result.

Examples:
To get list of all the bank accounts, execute:
GET bank/account/_search

To get all the bank acconuts from California (State will be CA):
GET bank/account/_search
{
  "query": {
    "match": {"state": "CA"}
  }
}

To get all the bank acconuts of Techade from California (State will be CA)
GET bank/account/_search
{
  "query": {
    "bool": {
      "must": [
        { "match": {"state": "CA"} },
        { "match": {"employer": "Techade"}}
      ]
    }
  }
}

To get all the bank acconuts not from Techade and outside California (State will be CA)
GET bank/account/_search
{
  "query": {
    "bool": {
      "must_not": [
        { "match": {"state": "CA"} },
        { "match": {"employer": "Techade"}}
      ]
    }
  }
}

-K Himaanshu Shuklaa..

Part 5: Elastic Search Interview Questions And Answers(Hands On)

How to check health of cluster and node?
Start ElasticSearch and Kibana, and then open Kibana dashboard (you can open it with this URL  http://localhost:5601/app/kibana#/dev_tools/console)

to check health of cluster execute:
GET _cat/health?v

April 16, 2020

Part 4: Elastic Search Interview Questions And Answers

What is ELK Stack and its contents?
Enterprises, large or small nowadays come across information in the form of reports, data and customer follow-ups and historical, current orders as well as customer reviews from the online and offline logs. It is essential to store and analyze these logs which will help predict valuable feedback for the businesses.

Part 3: Elastic Search Interview Questions And Answers

What is an Elasticsearch Analyzer? What are the various types of analyzers in Elasticsearch?
Analyzers are used for Text analysis, it can be either built-in analyzer or custom analyzer.

The analyzer consists of zero or more character filters, at least one Tokenizer and zero or more Token filters.

Part 2: Elastic Search Interview Questions And Answers

Explain the procedure to add or create an index in Elasticsearch Cluster?
To add a new index, create an index API option should be used. The parameters required to create the index is Configuration setting of an index, Fields mapping in the index as well as Index aliases.

Part 1: Elastic Search Interview Questions And Answers

Explain in brief about Elasticsearch?
Elasticsearch is an open-source, RESTful, scalable, built on Apache Lucene library, document-based search engine. It stores retrieve and manage textual, numerical, geospatial, structured and unstructured data in the form of JSON documents using CRUD REST API or ingestion tools such as Logstash.

January 28, 2020

#MongoDB Part 6: Interview Questions And Answers

How to create User and add Role in MongoDB?
Creating Admin User
We can create a user administrator in MongoDB by using the createUser method. e.g:

db.createUser(
{
   user: "myadmin",
   pwd: "password@123",
   roles:[{role: "userAdminAnyDatabase", db:"admin"}]
});

January 27, 2020

#MongoDB Part 5: Interview Questions And Answers

What is Mongo shell?
Mongo shell is a JavaScript interface to MongoDB that can be used to query and update data. It is interactive and can also be used to do administrative operations.

What is BSON?
BSON or binary JSON is the binary encoded format of JSON. It extends JSON and provides more data types and fields.

#MongoDB Part 4: Interview Questions And Answers

What is Namespace in MongoDB?
MongoDB stores BSON (Binary Interchange and Structure Object Notation) objects in the collection. The concatenation of the collection name and database name is called a namespace.

#MongoDB Part 3: Interview Questions And Answers

How to query a document in MongoDB using find()?
db.collection.find () is used for retrieval of documents from a MongoDB database. The find command is an in-built function which is used to retrieve the documents in the collection.

#MongoDB Part 2: Interview Questions And Answers

How to create Database and Collection in MongoDB?
In MongoDB, the database is used to store all of the collections, and the collection in turn is used to store all of the documents. The documents contain the relevant Field name and Field values.

#MongoDB Part 1: Interview Questions And Answers

What is MongoDB?
MongoDB is a document-oriented NoSQL database used for high volume data storage.
Instead of using tables and rows as in the traditional relational databases, MongoDB makes use of collections and documents. Documents consist of key-value pairs which are the basic unit of data in MongoDB. Collections contain sets of documents and function which is the equivalent of relational database tables.

January 01, 2020

Cassandra Interview Questions And Answers

What is NoSQL Database?
  • A NoSQL database is sometimes called as Not Only SQL. It is a database that provides a mechanism to store and retrieve data other than the tabular relations used in relational databases. 
  • These type databases are schema-free, support easy replication, have simple API, eventually consistent, and can handle huge amounts of data.
  • Primary objective of a NoSQL database is to have: simplicity of design, horizontal scaling, and finer control over availability.
  • SQL was designed to be a query language for relational databases, and relational databases are usually table- based, much like what we see in a spreadsheet. In a relational database, records are stored in rows and then the columns represent fields in each row. SQL allows we to query within and between tables in that relational database.
  • On the other hand, NoSQL databases are more flexible, NoSQL databases allow we to define fields as we create a record.
  • Nested values are common in NoSQL databases. We can have hashes and arrays and objects, and then nest more objects and arrays and hashes within those.
  • Also fields are not standardized between records in NoSQL databases, we can have a different structure for every record in your NoSQL database.

December 01, 2019

#Neo4j Part 8:Interview Questions & Answers

How files are stored in Neo4j?
Neo4j stores graph data in a number of different store files, and each store file consists of the data for a specific part of the graph(relationships, nodes, properties etc), e.g: Neostore.nodestore.db, neostore.propertystore.db and so on.

November 11, 2019

#Cassandra Part 4

Command To Create Keyspace
CREATE KEYSPACE EmployeeDetails
WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 3};

To verify whether the table is created or not we can use the command Describe. If we use this command over keyspaces, it will display all the keyspaces created.
DESCRIBE keyspaces;

#Cassandra Part 3

Define commit log.
It is a mechanism that is used to recover data in case the database crashes. Every operation that is carried out is saved in the commit log. Using this the data can be recovered.

#Cassandra Part 2 : Data Model, Keys, Ring Representation, Virtual Nodes

Cassandra
  • Cassandra is an open source, distributed database from Apache that is highly scalable and designed to manage very large amounts of structured data.
  • Cassandra is made to easily deploy over a cluster of machines located at geographically different places.
  • There is no master slave or central master server, so no single point of failure, no bottleneck, data is replicated, and a faulty node can be replaced without any downtime.
  • Cassandra is linearly scalable, which means that with more nodes, the requests served per second per node will not go down. Also, the total throughput of the system will increase with each node being added. 
  • Cassandra is column oriented, much like a map (or better, a map of sorted maps) or a table with flexible columns where each column is essentially a key-value pair. So, we can add columns as we go, and each row can have a different set of columns (key-value).
  • Cassandra does not provide any relational integrity. It is up to the application developer to perform relation management.
  • It is a type of NoSQL database.
  • Apache HBase and MongoDB are quite popular NoSQL databases besides Cassandra.
  • It is widely used in Netflix, eBay, GitHub, Facebook, Twitter etc.
  • Cassandra does automatic partitioning and replication.
What is the main objective of creating Cassandra?
The main objective of Cassandra is to handle a large amount of data. Furthermore, the objective also ensures fault tolerance with the swift transfer of data.

#Cassandra Part 1: NoSQLDatabase

NoSQLDatabase
  • A NoSQL database is sometimes called as Not Only SQL. It is a database that provides a mechanism to store and retrieve data other than the tabular relations used in relational databases. 
  • These type databases are schema-free, support easy replication, have simple API, eventually consistent, and can handle huge amounts of data.
  • Primary objective of a NoSQL database is to have: simplicity of design, horizontal scaling, and finer control over availability.
  • SQL was designed to be a query language for relational databases, and relational databases are usually table- based, much like what we see in a spreadsheet. In a relational database, records are stored in rows and then the columns represent fields in each row. SQL allows us to query within and between tables in that relational database.
  • On the other hand, NoSQL databases are more flexible, NoSQL databases allow us to define fields as we create a record.
  • Nested values are common in NoSQL databases. We can have hashes and arrays and objects, and then nest more objects and arrays and hashes within those.
  • Also fields are not standardized between records in NoSQL databases, we can have a different structure for every record in your NoSQL database.

October 01, 2019

#Neo4j Part 7:Interview Questions & Answers (Return, Order By, Limit, Skip, With, Unwind clause)

Explain Return clause of Neo4j.
We can return  nodes, relationships, and properties in Neo4j by using Return clause.

Returning Nodes:
Create (node:label {properties}) RETURN node 

#Neo4j Part 6:Interview Questions & Answers (Match, Optional Match, Where and Count clause)

Explain Match clause of Neo4j.
Get All Nodes Using Match: With Match clause we can retrieve all nodes in the Neo4j database. Query to return all the nodes in Neo4j database.
MATCH (n) RETURN n 

Getting All Nodes Under a Specific Label: We can get all the nodes under a specific label.
MATCH (node:label) RETURN node 

Match by Relationship: We can retrieve nodes based on relationship using the MATCH clause.
MATCH (node:label)<- i="" n="" nbsp="" relationship="" return="">

Delete All Nodes: We can delete all the nodes using the MATCH clause.
MATCH (n) detach delete n