Latest Entries »

Sunday, November 7, 2010

solution for prototype.js and jquery.js conflict problems

Jquery have provide a solution for prototype.js and jquery.js conflicts. There is one caveat: By default, jQuery uses "$" as a shortcut for "jQuery". However, you can override that default by calling jQuery.noConflict() at any point after jQuery and the other library have both loaded. For example:

<script src="prototype.js"><⁄script>
<script src="jquery.js"><⁄script>
var $j =jQuery.noConflict();

⁄ ⁄ Use jQuery via $j(...)
var textbox1 = $j('#textbox1').val();


⁄ ⁄ Use Prototype with $(...)


Monday, October 18, 2010

How to set Cent OS date and time

By entering following command line, we can change the system date of Cent OS

[root@localhost ~]# date <month by 2 digits><date by 2 digits><hour by 2 digits in 24 hour format><minutes by 2 digits><year by 4 digits>

        date 101812472010

Saturday, September 25, 2010

How to create mysql stored procedure (without using mysql-query-browser)

How to create mysql stored procedure (without using mysql-query-browser)

In here I'm explaning to simple creating mysql stored procedure without using mysql query browser. So let’s say hello using mysql stored procedure.

1) First you have to open text editor to write the mysql procdure code. So windows users can use notepad and linux users can use vim for that.  File name is “hello.sql”. The file format should be “.sql”.

2) Write the following code on your text editor,  and save.


DROP PROCEDURE IF EXISTS `test`.`hello` $$
CREATE PROCEDURE `test`.`hello`()
SELECT 'hello';
END $$


3) Explanation about the code

Normally mysql user ";" as the end of a statement (delimiter).  But since stored procedures contain semicolons in the procedure body, we need to use a different delimiter to identify the end of the procedure. Therefore in here I’m using “$$” as delimiter of the procedures. To define the delimiter we can use DELIMITER key word as the first line of the above code.

DROP PROCEDURE IF EXISTS `test`.`hello`$$ ” line will remove the stored procedure if it already exists in the test database. In here you can see I have use “$$” procedure delimiter as the end of the statement.

CREATE PROCEDURE `test`.`hello`() “ line is the start of a stored procedure definition. “hello” is the name of the procedure.

BEGIN “ line is the start of the stored procedure program.

Between BEGIN and END we can write the procedure program with using sql stetments. And we use “;” as the delimiter in the program. “SELECT 'hello'; “ is the simplest sql statement.

END $$ ” line ends the procedure program, and it use “$$” delimiter.

After the end of procedure we should redefine the delimiter to “;” for normal use by "DELIMITER ;".

4) Now you should log on to the mysql database in command line. 
(Windows users should go to the C:\Program Files\MySQL\MySQL Server 5.1…\bin\ where the mysql.exe located)
# Mysql –u –p

5) After login to the mysql you should type SOURCE Hello.sql

Example for linux:
mysql> SOURCE /home/Hello.sql

Example for windows: 
mysql > SOURCE D:/Hello.sql

6) After that you should type following code to run the procedure.
CALL test.hello(); 
USE test;
CALL hello();

The out put,
| Hello |
| Hello |

Wednesday, August 18, 2010

Database Normalization (1 to 3rd form)

In the relational database design, normalization is a systematic way of ensuring that a database structure is suitable for querying without insertion, update, and deletion anomalies that could lead to a loss of data integrity.

1st Normal Form
First you have to know what are the multivalued and composite attributes to understand the 1st normal form.

Multivalued Attribute is a attribute which can have more then a single value. For an example we can take a  person's telephone number. We can take many numbers as telephone number (Home tel number,Mobile number, tel number at office). To remove a multivalued attribute we have to divide the attribute.
Example: If we have attribute called "telephone", then we can divide it as "home telephone", "mobile number", "office number".

Composite attribute is a attribute which have several attributes. For an example the address attribute is can take as composite attribute. To remove this attribute we can divide the attribute to the sub attributes.
Example: If we have attribute called "address", then we can divide it to "no.", "street1", "street2", "city", "country".

These kind of attributes (multivalued and composite) should removed from the relation schema to get first normal form relation.

2nd Normal Form
In the 2nd normal form it consider two dependencies called Functional dependencies and Partial dependencies. And also you should have the knowledge of primary key of a relational schema.

Functional dependency occurs when one attribute in a relation uniquely determines another attribute.

Partial dependency occurs when non-key attribute in a relation uniquely determines by sub set of primary key attribute set. Therefore to occur these kind of dependencies the primary key should contain more than one attributes.

All attributes in a relational schema should be fully functionally depend on the primary key of that relational schema. It means there should not occur any partial dependencies.

3rd Normal Form
relational schema which have no transitive dependencies, called 3rd normal formed relational schema. transitive dependency occurs when a non-key attribute in a relational schema depends on another non-key attribute.

Monday, August 16, 2010

Simple Linux shell script ( for beginners)

Here I'm going to show you how to write a simple Linux shell script to print "Hello World" in the Linux command line.

Step 1 : To go to the home folder, type "cd /home" and press 'Enter' key.

Step 2 : To open a new file, type "vi" and press 'Enter' key.

Step 3 : Press 'Insert' key and write following code;

#clear for clear the screen
#echo for print Hello World
echo "Hello World"

Step 4 : Press 'Esc' key and type ":wq" and press 'Enter' key to save the file.

Step 5 : Now type "ls" to list the file and check the file was created.

Step 6 : Now type "chmod +x" and press 'Enter' key to make it as executable file.

Step 7 : Check the files again by typing "ls". the file will be show in green color.

Step 8 : To run the shell script, type "./" and press 'Enter' key. This will print "Hello World" in your screen.

This is the simplest shell script that you can star get familiar with writing Linux shell scripts, and explore the advance shell scripts.