What is “Yes”Sql?
Question :- Do you know what we can use to store all employees data?
Answer :- Yes! I would use a RDBMS (Relational Database Management System) software like Sql Server,
MySql, Oracle etc. I would store all your employee data in different database tables with relationships between them.
Question :- Do you know how can we can access and manage employees data?
Answer :- Yes! I would use a query language named SQL (Structured Query Language) to query and manage data.
If you have been also answering “Yes” to the above questions, you have been doing “Yes”SQL. I have been doing the “Yes”SQL for quite some time and feeling like the frog in its well of RBMS’s without even realizing the outside world has become better and should be explored.
source :- http://bit.ly/VVxmMU
What is NoSql
What is NoSQL
As we have been doing “Yes”SQL for quite some time, we will first take a look at what we have been doing for
storing and retrieving data.
Following is very simplified employee database tables.
Add some data:-
INSERT INTO Department(Id, Name) VALUES(1, ‘Accounts’)
INSERT INTO Department(Id, Name) VALUES(2, ‘Engineering’)
INSERT INTO Employee (ID, Name, DepartmentID) VALUES (1, ‘Ashish’, 1)
INSERT INTO Employee (ID, Name, DepartmentID) VALUES (2, ‘John’, 2)
If we want to retrieve name of the employee and the department in which he/she works using the employee id,
need to join the two tables :-
SELECT E.Name AS EmployeeName, D.Name AS DepartmentName FROM Employee E
INNER JOIN Department D ON E.DepartmentID = D.Id
WHERE E.Id = 1
Why we needed to join the tables? because all the information for that particular employee is not stored at one table. This is the main characteristic of a RDBMS and this is first thing we need to get off our minds in NoSQL.
Now, there are different types of NoSQL databases – Raven DB, Mongo DB etc. However, in all of them, the basic element is same – No relationship!
In Raven Db, the all data for this employee would be stored in a “document”.
As you see – all data (which includes department details as well) for employee with id “1” is stored in one
place – a “document”, in RavenDB terms. This is similar to a “row” in the RDBMS except the fact that data is not distributed in different tables, rather all data is at one place – in a document. For each employee, there would be be one document.
NoSQL using RavenDB
What is Raven Db
Raven DB is a document database. It has following characteristics :-
- Non- Relational
- All data is stored and represented in JSON
- There is no schema
I downloaded the last stable build of Raven DB and extracted to my local “D:\Ashish\Research\RavenDB” folder. Look for /Server/RavenServer.exe.config and change the Anonymous access to “All”
It should open a very nice looking management studio for Raven Db (performing function “similar” to SQL server management studio). It will ask you to create a new database as you don’t have any. Put a name for the database.
Below is the client code which when executed creates one document per entity (in this example, a company). Notice that a DocumentStore is similar to a connection. We can use the same connection to create multiple documents. However, each document is bound to a session and that’s why It needs to be disposed before creating a new one. Also notice the RabenDb displays the documents created in the server admin browser.