Archive for November, 2009

Introduction
Unless you have been living in a cave somewhere without Internet access for the last few years, you have undoubtedly heard of XML, SOAP and Multi-Tiered Application Programming. If you are like many programmers, including myself, you were quite taken aback by these ideas and technologies. You may have gone so far as to simply dismiss them as irrelevant to your skill set. It’s time to wake up and realize they’re hereto stay… and for good reason!.

XML and SOAP, and in turn Multi-Tiered Programming, are technologies that can take you from being a run of the mill code hacker to a professional application developer that actually builds cool things that work and which other people can work on. These technologies enable you to build applications that separate data from presentation, keep things organized and enable your application to scale as your needs and user base increases. (more…)

Advertisements

Database Normalization Rules

Posted: November 17, 2009 in SQL

SQL-based English Query applications work best with normalized databases. In general, it is easiest to create English Query applications against normalized SQL databases. In addition, the resulting applications are more flexible and powerful than those developed against databases that are not normalized.

This topic describes normalization rules as they pertain to English Query SQL applications. It describes problematic database structures that break these rules and how to solve these problems by creating views in Microsoft® SQL Server™, which can be used in English Query just like any other table.

Rule 1: There should be a one-to-one relationship between the instances of an entity and the rows of the table.

For every table that represents an entity, each and every row in that table should represent one and only one instance of that entity. Conversely, each and every instance of that entity should be represented by one and only one row in the table.

In this situation, this rule is not met:

Table:    Employees
Fields:    Emp_id, Emp_name, Status, Position, Salary
Keys:    Emp_id, Status

This table stores information about employees. It contains their names, positions, and salaries. But sometimes employees move around from position to position, and when they do, their salaries change. So for some employees, this table also stores information about their projected position and salary. If the value of the Status field is C, the row contains the current information for the employee. If the value is P, it contains the projected information. Thus, an individual employee may appear twice in this table.

Because an employee can appear twice, you cannot use this table to represent the employees entity. If you were to associate the employees entity with this table, even simple requests, such as “Count the employees”, would give the wrong answer. The solution to this problem is to create a view in the database that contains a single row for each employee and to tell English Query about this view.

Here is what the view would look like:

CREATE VIEW Emps AS
SELECT Emp_id, Emp_name, Position, Salary
FROM employees
WHERE status = 'C'

You now have a view that contains exactly one row per employee. The employees entity can now be represented by this view.  (more…)

SQL Performance Tips

Posted: November 17, 2009 in SQL

SQL Performance Tips :-

  1. Use EXPLAIN to profile the query execution plan
  2. Use Slow Query Log (always have it on!)
  3. Don’t use DISTINCT when you have or could use GROUP BY
  4. Insert performance
    1. Batch INSERT and REPLACE
    2. Use LOAD DATA instead of INSERT
  5. LIMIT m,n may not be as fast as it sounds
  6. Don’t use ORDER BY RAND() if you have > ~2K records
  7. Use SQL_NO_CACHE when you are SELECTing frequently updated data or large sets of data
  8. Avoid wildcards at the start of LIKE queries
  9. Avoid correlated subqueries and in select and where clause (try to avoid in)
  10. No calculated comparisons — isolate indexed columns (more…)

HTTP Error Codes

Posted: November 13, 2009 in Technology

Information Codes

Error #

Error Code

100

Continue

101

Switching Protocols

Success Codes

Error #

Error Code

200

OK

201

Created

202

Accepted

203

Non-Authoritative Information

204

No Content

205

Reset Content

206

Partial Content

(more…)

Using Views in Drupal 6

Posted: November 11, 2009 in Technology

Drupal 6 has been out for a while now and modules are getting ported to the new version. For those of us that are relatively new to Drupal it has been a long slow wait – but the benefit is that we have a bit of extra motivation to learn and do “stuff” for ourselves.

If the search for cool modules and functions on the Drupal site one thing you begin to see is the importance of modules that might not necessarily supply a prebuilt function, like a calendar for example, but provide the ability to define new types, views, or displays of data from either your Drupal site or a different source. The modules I’ve been exploring are:
• Feed Aggregator
• CCK
• Views
• Panels
(more…)

What happens If INR 1 Rs = USD $ 100

Posted: November 11, 2009 in Fun

Year : 2050
Place : IBM , USA
(Two Americans Talking)
Currency Conversion Rate : INR 1 Rs = USD $ 100
Alex: Hi John, you didn’t come yesterday to office?
John: Yeah, I was in Indian Embassy for stamping.
Alex: Oh really, what happened, I heard that nowadays it has become very strict.
John: Yeah, but I managed to get it.
Alex: How long it took to get it stamped?
John: Oh, it was nasty man, long queue. Bill Gates was standing in front of me and they played with him like anything. That’s why it got delayed. I went there at 2 AM itself and waited and returned by 4 PM .
Alex: Really? In India , it is a matter of an hour to get stamped for USA
John: Yeah, but that is because who in India will be interested in coming to USA man, their economy has been booming. (more…)

How To Use Prototype.js On Your Site

Posted: November 10, 2009 in Technology

prototype.js is an amazing JavaScript framework that I have been using for some years now. This tutorial shows you how to work with prototype.js and what some best practices are. It won’t go into details on every available method but it will give you a quick introduction.

I apologize for the coding style but the WordPress plugin seems to eat spaces and tabs.

Obtaining Prototype.js

You can download the latest version of the prototype library from the download page and include this on your page like this if you have saved it as prototype.js in your document root directory:

<html>

<head>

<script src=”prototype.js” type=”text/javascript”></script>

</html>

There are also some packaged and minimized versions of the file available because the file itself is quite large.

Using Google To Load Prototype.js

(more…)