Wednesday, January 20, 2010

Difference Between UNIQUE and PRIMARY KEY columns

0 comments
What is the difference between UNIQUE and PRIMARY KEY columns?

With the primary key column we can identify rows of a table in a unique manner. This is very important when it comes to database programming. On the other hand, a unique key column,
  • forbids having identical values on the field. For example, If you have column for storing names you can not have two same names. Data should be unique.
  • You can have more than one unique key columns
  • is allowed to accept NULL values. This is the differentiating factor between primary key and unique key. Primary key does not allow NULL values.
See the below example.




ID
Name
City
1
Rose
Chicago
2
Mike
San Antonio
3
Null
Chicago
4
Lian
Chicago


Here ID column is primary key and "Name" column is a unique key.
Read full story

Tuesday, December 1, 2009

Regular Expression for Numbers only validation

0 comments
For the new site i'm working on, I wanted to validate the user input for allowing only to enter a numeric value with or without decimal points. So i decided to use a Regular Expression. After some time I came up with his solution.

Ok If you want to match a floating point numbers use this ^[0-9]*\.?[0-9]+$
You can use this to validate whether a user has entered a number (2) or number with decimals (2.45453).

But if you only want to match whole numbers like 2, 3, 333, 545 etc. use this ^[0-9]+$

How to match a specific number of numeric characters
For example, If I want 10 digit numeric character set - ^[0-9]{10}$
Read full story

Monday, November 23, 2009

How To Install 7zip in Fedora

1 comments
If you are looking for a free file archiving software, well 7zip would be the answer. 7-Zip is open source software. Most of the source code is under the GNU LGPL license.




7Zip  is better than winrar, winzip etc. If you are looking to install this peace of software in your fedora machine, the easiest way is to do a yum install. Here is the code that you need to use.

How To Install 7zip in Fedora

1. Open up the Terminal

2. Login as root
enter the command su -
It will now prompt you for the password. Type root password and hit enter.

3. Type the following code
yum install p7zip

The package will be installed for you.
Read full story