Advantage of MongoDB

Advantage of MongoDB 
In MongoDB there is no concept of the relationship while RDBMS has a typical schema design that shows all tables and the relationship between these tables. On enterprise level relational database face more difficulty due to accessing of records, performance etc.  Below I am trying to explain the advantage of MongoDB over RDBMS.
Advantages of MongoDB in excess of RDBMS
  • Schema-less: A collection can hold more than one document with different structure means a number of fields, content size of the document can be different to one another.  See below pic.

A person is a collection which has two documents with different structure first document did not have field middleName while second have.
  • It has cleared Structure of a single object.
  • No complex joins
  • Deep query-ability:  MongoDB supports dynamic queries on documents using a document-based query language that's nearly as powerful as SQL
  • Ease of scale-out: MongoDB is easy to scale
  • Conversion / mapping of application objects to database objects not needed
  • Uses internal memory for storing the (windowed) working set, enabling faster access to data
  • No schema migrations: Since MongoDB is schema-free, your code defines your schema.
Why should use MongoDB
  • Document Oriented Storage: Data is stored in the form of JSON style documents
  • Index on any attribute
  • Replication & High Availability
  • Auto-Sharding
  • Rich Queries
  • Fast In-Place Updates
Where should use MongoDB?
  • Big Data
  • Content Management and Delivery
  • Mobile and Social Infrastructure
  • User Data Management
  • Data Hub

MongoDB Overview

I have started to work with MongoDB so think to start blogging about MongoDB. I will try to write very simple language which will give you great understanding on MongoDB concept to create and deploy a highly scalable and performance-oriented database.
MongoDB is an open-source document database is written in c++, and leading NoSQL database.
MongoDB is a cross-platform, document-oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on the concept of collection and document.
Database: Database physically contains the collections. Each database gets its own set of files on the file system. A single MongoDB server usually has multiple databases.
Collection: This is equivalent to RDBMS table; basically collection is a group of MongoDB Documents. A collection exists within a single database. Collections do not insist on a schema. Documents within a collection can have different fields. Naturally, all documents in a collection are of similar or related purposes.
Document: Document is a set of key-value pairs. Documents have a dynamic schema. Dynamic schema means that documents in the same collection do not need to have the same set of fields or structure, and common fields in a collection's documents may hold different types of data.

Table Join
Embedded Documents
Primary Key
Primary Key (Default key _id provided by MongoDB itself)
Database Server and Client

Sample document
Below given example shows the document structure of a blog website which is simply a comma-separated key-value pair

   _id: ObjectId(4gf66u875)
   title: 'MongoDB Overview',
   description: 'MongoDB is no sql database',
   by: 'codefari',
   url: '',
   tags: ['mongodb', 'database', 'NoSQL'],
   likes: 100,
   comments: [  
         message: 'My first comment',
         dateCreated: new Date(2015,1,20,2,43),
         like: 0
         message: 'My second comments',
         dateCreated: new Date(2015,1,25,7,34),
         like: 5
_id is a 12 bytes hexadecimal number which assures the uniqueness of every document. You can provide _id while inserting the document. If you didn't provide then MongoDB provide a unique id for every document. These 12 bytes first 4 bytes for the current timestamp, next 3 bytes for machine id, next 2 bytes for process id of MongoDB server and remaining 3 bytes are simple incremental value.

get the selected items in checkboxlist

There are many ways to get items from CheckBoxList. Bellow some codes are presented.
On aspx page,
<asp:CheckBoxList ID="chkbokxlist" runat="server"></asp:CheckBoxList> 
1- Code behind 
       foreach (ListItem i in chkbokxlist.Items)
            if (i.Selected)
            //your code here
2- Code behind
        var itm = chkbokxlist.Items.Cast<ListItem>().Where(x => x.Selected);
        foreach (ListItem i in itm)
            if (i.Selected)
            // your code

what is named parameters in c#

Visual Studio 2010 and above give us a facility to specify an argument for a particular parameter by associating the arguments with the parameter's name rather than with the parameter's position in the parameter list.
For example:
    public class Employee
        public Employee()
        { }
        public void emp(string fName, string lName, decimal salary)
        // here your code
        public void Main(string[] args)
           emp(fName: "dilip", lName: "Singh",salary: 10000);
           emp(salary: 10000, fName: "dilip", lName: "Singh");

Difference between Get Method and Post Method in

Get Method
1 - Data will be arranged in HTTP header by appending to the URL as a query string.
2 - Data is publicly available (Data is in query string so the user can view the data).
3 – It can save only 4k data.
4 – Only ASCII character data type is allowed.
5 – Caching is possible.

Post Method
1 - Post data can be appended to the body as well in URL also.
2 – Data is secret for https otherwise public.
3 – There is no limit on the amount of data.
4 – It allows binary data also.
5 – caching is not possible.

PostgreSQL-Query: Sort result set by specific field values using ORDER BY Clause

Problem: Suppose we have a book_inventory table which has some columns such as id, isbn, title, author, publisher, publish_date, etc.. whe...