Skip to main content

Posts

Showing posts with the label mongodb vs sql server

Create Function in SQL Server

--================================ --CREATE FUNCTION WITH PARAMETERS. --================================ CREATE FUNCTION AddFun1 (@NumIst INT ,@NumpIInd INT ) RETURNS INT AS BEGIN DECLARE @Result AS INT SET @Result = @NumIst + @NumpIInd RETURN @Result END ----RESULT LOOKS LIKE, Print test . dbo .AddFun1( 10 , 20 ) --IS 30

T-SQL Columns, Tables Alias

In SQL, we can alias columns, views and tables. A table alias is also called a co-relation name. It is a temporarily names of columns or tables. The Alias temporarily assigns another name to a column, or table at the time of a SELECT query and the assigning alias doesn’t rename the column or table name actually! Basically, it make column, or table more readable to the programmers. Syntax: --USE OF TABLE ALIAS SELECT TBL . Id , TBL . Name FROM [dbo].[Tbl_Demo] AS TBL WHERE TBL . Id in ( 1 , 2 , 3 ) --USE OF COLUMN ALIAS SELECT TBL . Id AS UID, TBL . Name AS UNAME FROM [dbo].[Tbl_Demo] AS TBL WHERE TBL . Id in ( 1 , 2 , 3 )

Mongodb advantages and disadvantages

Advantages of MongoDB o     MongoDb is document database. o     Lightening is very fast. o     MongoDb provides ACID properties at the document level. o     MongoDb handled failover mechanism is automatically. o     MongoDb supports common authentication mechanisms like LDAP, AD. o     Auto sharding because MongoDB enables horizontal scalability. o     Replication is very easy. o     You can perform rich queries. Disadvantages o     Not support joins operation. o     Not support transaction . o     No single server durability. If query is crashes   that time you lost your all data and after repair you lost approx. 50 to 60% data. o     Indexes take up a lot of RAM (RAM limitation). o     Memory limitations. “ MongoDB  lacks some features of rel...

MongoDb aggregation if else

Syntax: { $cond : [<expression>, <true>, <false>] } Example as given below db . Customers . aggregate ( [     { "$project": {         "name": 1,         "customer": {             "$cond": {                 "if": { "$eq": [ "$Age", 25 ] },                 "then" : "YG" ,                 "else" : {                     "$cond" : {                         "if" : { "$eq" ...

How to sort a collection by date in MongoDb?

In MongoDb , different ways of sorting can perform on a collection and you can use 1 for ‘asc’|ascending and -1 for ‘desc’|descending. Syntax: db . collection . find (). sort ( { column1: 1 or - 1 [, column2: 1 or -1] }); For example, db . customers . find (). sort ({ CreatedDate: 'desc' }). toArray ( function ( error ,   items ) {});                                                             OR db . customers . find (). sort ( 'CreatedDate' , 'desc' ). toArray ( function ( error ,   items ) {});                            ...

Mongodb if else statement

According to MongoDb  docs, $cond "evaluates a Boolean expression to return one of the two specified return expressions". Syntax: { $cond : { if: < expression >,                      then: < true >,                     else: < false >        } } OR { $cond : [<expression>, <true>, <false>] } Example for MongoDb if else statement db . customers . aggregate (    [{          $project:            {              C_Id: 1,              C_Type:     ...

MongoDB vs. SQL Server

The MongoDB  store the data in documents with JSON format but SQL store the data in Table format. The MongoDB provides high performance, high availability, easy scalability etc.  rather than SQL Server. MongoDB mentioned to document-based NoSQL databases but SQL Server mentioned to relational database. MongoDB is a NoSQL  database so there's nothing like a stored procedure. You can create a set of common functionality in a class library. The "fire-and-forget"  is a default option to check query operations but we can use to " getLastError " method to check query operations succeeded or not. In the MongoDB, we can change the structure simply by adding, removing column from the existing documents. For SQL Server to MongoDB mapping chart, go to live link https://docs.mongodb.org/manual/reference/sql-comparison/     For more detail, go to below link. http://stackoverflow.com/questions/13190468/pros-and-cons-of-using-mongodb-inste...