Latest Entries »

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 hello.sh" and press 'Enter' key.

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


#!/bin/sh
#clear for clear the screen
clear
#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 hello.sh" 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 "./hello.sh" 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.