Geometrical (12-21-2013)
Recently I've developed my own NoSQL data storage engine so in this tutorial I'll be using mine (which is available in my sig). First of all include the namespace for the database.Originally Posted by Wikipedia
In this example I'll be creating a database to store each company employee information.Code:using eGamers;
Now to create a new database we'll be using a random file in our PC to store the data. (If the file doesn't exist it will be created automatically) To do so just initialize a new instance of the EGNoSqlDatabase class.
Alright, so we have a file that holds our database, now we need to fill that database with concrete data. To do so we must first of all understand its data model which is very understandable...Code:EGNoSqlDatabase testDB = new EGNoSqlDatabase(@"D:\testDB.db", "The Database Name");
[IMG]https://egnosql.******.com/uploads/5/4/7/1/5471987/4539705_orig.jpg[/IMG]
So this is the data model. Now we have to add some rows to store our data.
There will be 4 employees, which means that we'll have to store 4 different rows. (This can be also done in a single row tho)
The good thing about all this is that a row can have different columns. Let's take an example:
As the model above shows there's no strict schema for the table. You can add as many columns per row as you wish.Code:________________________________________________________ |ROW #1 ________________________________________________________ Name Role Picture Salary Contract Expiration Date ------ ----- -------- ------- ------------------------ Ted Coder <PIC> $10000 05/01/2013 ________________________________________________________ ________________________________________________________ |ROW #2 ________________________________________________________ Name Salary ------ ------- John $500 ________________________________________________________
Now let's create the rows:
Code:List<EGNoSqlVirtualCell> cells = new List<EGNoSqlVirtualCell>(); // Create a new row for the employee Ted. cells.Add(new EGNoSqlVirtualCell("Name", Encoding.ASCII.GetString("Ted"))); Add the rest of the info as in the example above... EGNoSqlVirtualRow ted = new EGNoSqlVirtualRow(cells); cells.Clear(); // Create a new row for the employee John. cells.Add(new EGNoSqlVirtualCell("Name", Encoding.ASCII.GetString("John"))); Add the rest of the info as in the example above... EGNoSqlVirtualRow john = new EGNoSqlVirtualRow(cells); cells.Clear(); // Add each row to the database. testDB.AddRow(ted); testDB.AddRow(john); // Store the database to the file. testDB.SaveToFile();
So this was just a short intro into the NoSQL world! Expect it coming guys!
Geometrical (12-21-2013)