Showing posts with label Usage. Show all posts
Showing posts with label Usage. Show all posts

Wednesday, July 18, 2012

MongoDB Basics and Usage With Ruby on Rails

MongoDB is a collection-oriented, schema-free and document based database. It is scalable, high-performance, open source and written in C++. A key feature from a developer's perspective would
be its powerful query language.

The official site has pretty good documentation, so we will just summarize the key concepts here.

Terminology:

Document - is a group of key-value pairs (similar to a hash in ruby), where keys are strings and values are any of a rich set of supported data types. You can think of it as a row in a relational
database, with keys being the column names. Document data is stored in BSON ("Binary Serialized document Notation") format.

Example:
status = { posted_at: Date("2012-06-19T02:10:11.3Z"),
author: "Mohammad",
title: "Learning MongoDB basics",
text: "This can be a very long description... ",
tags: [ "MongoDB", "Rails" ],
likes: 20 }

BSON - is a binary-encoded serialization of JSON-like documents. BSON is designed to be lightweight, traversable, and efficient. BSON, like JSON, supports embedding of objects and arrays
within other objects and arrays.

Data Types - Mongo supports all basic JSON data types like string, integer, boolean, double, null, array, and object, as well as special data types like date, object_id, binary data, regular expression,
and code.

Collection - is a group of documents, usually having a similar structure. You can think of it as a table in a relational database.

Indexing - is similar to how it works in relational databases. Every document gets a default index on the "_id" attribute, which also acts as a primary key.

Embedding - is the nesting of objects and arrays inside a document like pre-joined data or like a 'view' in relational database. So, for example all the comments on a photo can be embedded
within the photo document itself instead of storing them in a different collection.

Example:

status = { posted_at: Date("2012-06-19T02:10:11.3Z"),
author: "Mohammad",
title: "Learning MongoDB basics",
text: "This can be a very long description... ",
tags: [ "MongoDB", "Rails" ],
likes: 20,
comments: [

{from "Chirag",
commented_at: Date("2012-06-19T02:50:11.3Z"),
comment "Yes, it is pretty cool!"}
]}

Links - are references between documents, like foreign keys.

Joins - are not supported in MongoDB. However, some data can be de-normalized and embedded within the parent document (like in the photo example above) to remove the need for joins.

Restrictions - Document element name cannot begin with "$" or contain a "" "_id" is reserved element name (primary key) and cannot be reused for any other purpose.

Syntax:

It would be good to try this out in a mongo console as we go.

Console
~$ mongo
> help // top level help
> db.help() // help on db-specific methods
> db.mycollection.help() // help on collection methods

Query
db.createCollection("users") // Create a new collection
db.users.find({}, {name:1,email:1}) // Get name and email of all users
db.users.find({age:33}, {name:1,email:1}) // Get name and email of all users older than 33 years
db.users.findOne({name: 'mohammad'}) // Find first document with a given name

Insert
db.users.insert({name: 'chirag')
doc = {name: 'mohammad', email: 'mohammad@rails.com'}
db.users.save(doc)

Update
db.users.update({name:'mohammad'}, {$set:{name:'Mohammad'}})

Delete & Drop
db.users.remove({name:'mohammad'})
db.users.drop()

For better understanding, you can go through SQL to Mongo reference here.

ORM for Rails:
There are several ActiveRecord replacements for MongoDB, but we have found MongoMapper to be the closest replacement. There is already a great Railscast on how to use MongoMapper with
Rails, so we won't cover that in this article.

Get more information on: Ruby on Rails
For more information visit: Web Application Developer


View the original article here

Tuesday, July 3, 2012

How Mobile Cloud Computing Benefits Development and Usage of Mobile Apps

Mobile cloud computing provides many advantages for application developers as well as their end-users. It is a boon for corporate users in particular, that do not have enough capital to invest upfront on required hardware and software.

Mobile applications have made smartphones "smart". The first wave of mobile apps were native apps, however with the increase in Internet capabilities for mobile devices, apps became faster and more powerful, as it was no longer necessary to manage the data storage and processing within the application.

Cloud computing changed mobile application development forever. With benefits like low initial investment, ease of adoption, scalability and elasticity, operational efficiency and large overall cost savings, it didn't take long for mobile app developers to adopt cloud computing.

Cloud computing offers the performance and flexibility that mobile app developers require. Because smartphones and tablets with advanced browsers are capable of accessing stored applications remotely in the cloud, developers can now build apps one time and deploy them across multiple platforms, including iPhones, iPads, Android devices, etc. In short order, more innovative and useful apps were developed more quickly and cost effectively. With this, the smartphone and app markets began to grow at a remarkable rate that shows no signs of slowing.

Advantages to the users
With cloud-based apps, mobile users do not need high-end hardware and infrastructure to run or maintain mobile apps. Businesses are able to pass along the reduced cost of development to their users, while improving the functionality of data sharing, and offering features like collaboration that were not previously feasible. All told, users with any Internet-enabled device can run many more apps and more powerful apps than ever before, at little or no cost.

Advantages to the developers
The advantages of cloud computing for mobile app developers are most pronounced. One, cost savings. Developers need not invest heavily in building infrastructure and resources. Cloud computing provides instant access to scalable mobile application tools for building mobile and tablet apps. Two, cross-platform app development. Developers can now build an app once and deploy across multiple platforms. And of course, building once and deploying to many devices dramatically reduces the cost of developing apps. Three, deploying apps to app stores and web sites is much easier. For example, developers can avoid device manufacturers or carrier app stores to distribute their apps, and publish them on their own private channels.

The future of mobile apps in the cloud
Despite the many advantages, cloud-based mobile apps will remain hampered by the limitation of wireless bandwidth capacity and intermittent network availability. We expect this will be a short-term problem as new developments in wireless technology are announced every day. In the meantime, alternate techniques like usage of HTML5, which does local caching, enable offline use of apps.

Overall, mobile cloud computing is strong and growing fast. When the limitations on connectivity are resolved, it will become the major player in development and usage of mobile apps.

Application Craft is the world's finest 100% cloud based development environment for mobile, tablet and desktop. If you are looking for a good ' mobile development platform ', we are a solid choice. Our IDE runs in your browser without plugins and despite being browser-based, it has all the power of a full-featured desktop application. Sign up now and build your first app free using our mobile application development tools.


View the original article here