Wednesday, June 20, 2012

Introducing SQLite

During the Windows 8 Metro App demos, there have been questions on SQLite. Until I started using it for my Windows 8 App, even I was not aware of the gem called SQLite. Thought of blogging additional information for everyone.

What was my requirement?

A lightweight database to store my contacts information for my Win 8 App. Need to ensure database is present on every machine or tablet which uses the app, so SQL Server / Oracle were immediately ruled out. Need an database which is lightweight, easy to install, and there are no licensing implications.

What did I use?

SQLite

What is SQLite?

SLite.Org describes it as follows: SQLite is a in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private. SQLite is currently found in more applications than we can count, including several high-profile projects.

SQLite is an embedded SQL database engine. Unlike most other SQL databases, SQLite does not have a separate server process. SQLite reads and writes directly to ordinary disk files. A complete SQL database with multiple tables, indices, triggers, and views, is contained in a single disk file. The database file format is cross-platform - you can freely copy a database between 32-bit and 64-bit systems or between big-endian and little-endian architectures. These features make SQLite a popular choice as an Application File Format.

Alternatives:

SQLite not as a replacement for SQL Server/Oracle, but a lightweight database. The other feasible alternative was to store the information in an XML file and insert/update the XML file using .Net framework classes.

SQLite for Windows 8:

SQLite team has announced that they are going to release an WinRT(Win 8) version of SQLite. It will be hopefully out before the RTM of Windows 8, and simplify the process of using it within an metro style app. However, it is not yet released as of today (19th June 2012).

So how did I use SQLite for my Windows 8 App?

I used the native SQLite DLL, and a .Net wrapper on top of it, which I got from my contact at Microsoft.

There are other .Net SQLite wrappers on CodePlex, but I haven’t been able to evaluate them. Ensure they are compatible with Win 8 consumer/release preview and pass the certification.

How big is my LibSQLite.dll?

756 KB.

I initially found it hard to believe that you can have an entire database engine in less than 1 MB.

How do I install?

This is the best part. It does not require any installation on end user machine. All I need to do is include it in my Visual Studio project, to ensure its present in my bin folder after code compilation.

Who else uses SQLite?

Countless apps. If you have a smart phone using Android, iPhone OS, Samsung Bada or Windows Phone OS, there are high chances that you have already have an app on your phone which uses SQLite.

Drawbacks/Limitations/Performance:

Inserting contact information for my 450 (and growing) Facebook friends, to my local SQLite database, is relatively slow and takes about 2 minutes.

There are ways and blogs to optimize SQLite performance which I need to look into.

Disclaimer: I had issues with running the app on tablets, and not sure what is the cause. SQLite can be one reason, but I have seen other Win 8 apps using SQLite running without any issues on tablets. So it’s likely that I have picked a wrong version of SQLite, or something else is causing the issue.

I am bad at SQL Data Definition Language syntax. How to I test my SQL JOIN queries?

If you have forgotten the SQL syntax that your probably learnt in college, no worries. You can use open source tools like  “SQLite Database Browser”. It’s a smaller, light weight version of SQL Server Management Studio(that we usually use for our enterprise projects). I create the tables and insert data using GUI, and then use the tool to create the equivalent SQL scripts for me. I also use the tool to test my SQL Queries and joins against the database, before using them in my code.

To know more:

SQLite:

http://www.sqlite.org/

Search on Google, and there are enough reference links and blogs on SQLite.

Though this email is written with SQLite for Win8 App as the background, the information is really generic and can be applied to other scenarios as well.

My experience with SQLite or App development is limited. If there is anything incorrect what I stated above, or better alternatives, do let me know.

Tuesday, June 05, 2012

Top 8 reasons why you should upgrade to Windows 8:



I upgraded from Windows 8 Consumer to Windows 8 Release Preview(RC) this week.
Update: I am now on Windows 8 RTM. Updated the content of post.

If you are still on an older operating system like Win XP / Windows 7, here are Top 8 reasons why you should upgrade to Win 8.

1. Faster Startup and Shut Down times
It takes only 10 seconds to startup and 5 seconds to shut down when I am on Win 8. My Win 7 OS on same hardware took around 2 minutes to startup and 1 minute to shut down.
2. Bring life to your PC – Use Modern( formerly called Metro Style) UI
Experience the Fast and Fluid Modern UI. Using it is the easiest way to learn the design principles of Modern UI.
3. It’s all about Apps
Play “Cut the Rope” with your friends and family. Compete on "Word-a-ment" with others. And enjoy the other great Apps available on the Windows 8 Store.
4. Practice what you preach & Early Adopter benefits
If you are an IT pro, use and experience Windows 8, before selling the same to customers. Embrace early to win the race. The early bird catcheth the worm, right.
5. Virtualize using Hyper-V on Windows 8
Windows 8 includes Hyper-V. Enable Hyper-V (described in my previous post here). Enable Hyper-V and setup your different environments.
6. Windows To Go
Carry your Windows 8 on a USB 3.0 stick with you. No need to carry the bulky laptops back and forth between Office and Home or while you are travelling.
7. Windows Everywhere
Use the same platform and Apps on your desktop, laptop, tablet, and now Windows Phone 8. Save settings once, and access it across different form factors.
8. .………………………………
Developing a Windows 8 App (‘What Time Is It?’) was my 8th reason. Will like to hear from you what’s your reason for upgrading to Windows 8.

Virtualization on Client OS – Part 3 – FAQ’s

 

In previous Post 1 and Post 2 of this series, I discussed the virtualization options on a Client OS. I will close the series by answering some FAQ.

Virtual Box needs 64 bit laptop, right?

First let’s discuss what do you mean by a 64 bit laptop/desktop? Do you mean OS or Hardware?

Almost all the Desktop/Laptop Hardware manufactured in last 5-6 years is 64 bit compatible. It can run both 32 bit and 64 bit OS. The desktop or the laptop that you might be using today is 64 bit compatible, but you might be running a 32 bit OS. Upgrade to 64 bit OS and the same Windows license key can be used.

For my SharePoint 2010 environments, I have upgraded a couple of desktops/laptops to 64 bit OS in past few years. I able to do it successfully on all but one laptop (Lenevo T60, 6 to 8 years old), which don’t have 64 bit compatible CPU.

Now coming to the question, whether Virtual Box requires 64 bit OS. As per documentation, it works on both 32 bit and 64 bit OS.

Can I run 32 bit Guest VM on 64 bit Host OS?

Yes, Both 32 bit and 64 bit Guest VM’s can be setup. Both Hyper-V and Virtual Box will allow that.

Can I run 64 bit Guest VM on 32 bit Host OS?

Yes for Virtual Box, under certain conditions documented below.

http://www.virtualbox.org/manual/ch03.html#intro-64bitguests

Hyper-V on Windows 8 is not available for 32 bit OS.