VIVEK SHAH

011011010010000001100001011001000110010001101001011000110111010001100101011001000010000001110100011011110010000001101010011000010111011001100001 Click Here

Custom Search


There are seven normal forms.
They are
  • First Normal Form
  • Second Normal Form
  • Third Normal Form
  • Boyce-Codd Normal Form
  • Fourth Normal Form
  • Fifth Normal Form
  • Sixth or Domain-key Normal form
Why do we need to do normalization?
To eliminate redundancy of data i.e. having same information stored at multiple places, which eventually be difficult to maintain and will also increase the size of our database.
With normalization we will have tables with fewer columns which will make data retrieval and insert, update and delete operations more efficient.
What do we mean when we say a table is not in normalized form?
Let’s take an example to understand this,
Say I want to create a database which stores my friends name and their top three favorite artists.
This database would be quite a simple so initially I’ll be having only one table in it say friends table. Here FID is the primary key.
FIDFNAMEFavoriteArtist
1SrihariAkon, The Corrs, Robbie Williams.
2ArvindEnigma, Chicane, Shania Twain

This table is not in normal form why?
FavoriteArtist column is not atomic or doesn’t have scalar value i.e. it has having more that one value.
Let’s modify this table
FIDFNAMEFavoriteArtist1FavoriteArtist2FavoriteArtist3
1SrihariAkon.The CorrsRobbie Williams.
2ArvindEnigmaChicaneShania Twain
This table is also not in normal form why?
We have now changed our table and now each column has only one value!! (So what’s left?)
Because here we are having multiple columns with same kind of value.
I.e. repeating group of data or repeating columns.
So what we need to do to make it normal or at least bring it in First Normal Form?
  1. We’ll first break our single table into two.
  2. Each table should have information about only one entity so it would be nice if we store our friend’s information in one table and his favorite artists’ information in another
(For simplicity we are working with few columns but in real world scenario there could be column like friend’s phone no, email , address and favorites artists albums, awards received by them, country etc. So in that case having two different tables would make complete sense)
FIDFNAME
1Srihari
2Arvind
FIDFavorite Artist
1Akon.
1The Corrs
1Robbie Williams
2Enigma
2Chicane
2Shania Twain
FID foreign key in FavoriteArtist table which refers to FID in our Friends Table.
Now we can say that our table is in first normal form.
Remember For First Normal Form
Column values should be atomic, scalar or should be holding single value
No repetition of information or values in multiple columns.
So what does Second Normal Form means?
For second normal form our database should already be in first normal form and every non-key column must depend on entire primary key.
Here we can say that our Friend database was already in second normal form l.
Why?
Because we don’t have composite primary key in our friends and favorite artists table.
Composite primary keys are- primary keys made up of more than one column. But there is no such thing in our database.
But still let’s try to understand second normal form with another example
This is our new table
GadgetsSupplierCostSupplier Address
HeadphoneAbaci123$New York
Mp3 PlayerSagas250$California
HeadphoneMayas100$London
In about table ITEM+SUPPLIER together form a composite primary key.
Let’s check for dependency
If I know gadget can I know the cost?
No same gadget is provided my different supplier at different rate.
If I know supplier can I know about the cost?
No because same supplier can provide me with different gadgets.
If I know both gadget and supplier can I know cost?
Yes than we can.
So cost is fully dependent (functionally dependent) on our composite primary key (Gadgets+Supplier)
Let’s start with another non-key column Supplier Address.
If I know gadget will I come to know about supplier address?
Obviously no.
If I know who the supplier is can I have it address?
Yes.
So here supplier is not completely dependent on (partial dependent) on our composite primary key (Gadgets+Supplier).
This table is surely not in Second Normal Form.
So what do we need to do to bring it in second normal form?
Here again we’ll break the table in two.
GadgetsSupplierCost
HeadphoneAbaci123$
Mp3 PlayerSagas250$
HeadphoneMayas100$
SupplierSupplier Address
AbaciNew York
SagasCalifornia
MayasLondon
We now how to normalize till second normal form.
But let’s take a break over here and learn some definitions and terms.
Composite Key: -Composite key is a primary key composed of multiple columns.
Functional Dependency – When value of one column is dependent on another column.
So that if value of one column changes the value of other column changes as well.
e.g. Supplier Address is functionally dependent on supplier name. If supplier’s name is changed in a record we need to change the supplier address as well.
S.Supplier–àS.SupplierAddress
“In our s table supplier address column is functionally dependent on the supplier column”
Partial Functional Dependency – A non-key column is dependent on some, but not all the columns in a composite primary key.
In our above example Supplier Address was partially dependent on our composite key columns (Gadgets+Supplier).
Transitive Dependencytransitive dependency is a type of functional dependency in which the value in a non-key column is determined by the value in another non-key column.
With these definitions in mind let’s move to Third Normal Form.
For a table in third normal form
  • It should already be in Second Normal Form.
  • There should be no transitive dependency, i.e. we shouldn’t have any non-key column depending on any other non-key column.
Again we need to make sure that the non-key columns depend upon the primary key and not on any other non-key column.
AlbumArtistNo. of tracksCountry
Come on overShania Twain11Canada
HistoryMichael Jackson15USA
UpShania Twain11Canada
MCMXC A.D.Enigma8Spain
The cross of changesEnigma10Spain
Although the above table looks fine but still there is something in it because of which we will normalize it further.
Album is the primary key of the above table.
Artist and No. of tracks are functionally dependent on the Album(primary key).
But can we say the same of Country as well?
In the above table Country value is getting repeated because of artist.
So in our above table Country column is depended on Artist column which is a non-key column.
So we will move that information in another table and could save table from redundancy i.e. repeating values of Country column.
AlbumArtistNo. of tracks
Come on overShania Twain11
HistoryMichael Jackson15
UpShania Twain11
MCMXC A.D.Enigma8
The cross of changesEnigma10
ArtistCountry
Shania TwainCanada
Michael JacksonUSA
EnigmaSpain
Normally this is considered enough and we don’t really go on applying the other normal forms.
Most of real-world application has databases which are in third normal forms.



Introduction

The main() method is probably one of the most familar structures in the Java language. It can easily be auto-generated in Eclipse by typing “main” followed by Ctrl-Space and in NetBeans by typing “psvm” followed by a space. It’s the entry point into thousands of applications and while it’s familiar, it also has a few hidden secrets. In this article we’ll look at more than a dozen variations of the main() method. Some will compile and run as expected. Others will not compile at all. Still others will compile and run, but can’t be used as an entry point into an application.


The Methods

Look at the methods below. Which ones will not compile? Which ones will compile, but can’t be used as entry points into an application? Which ones compile and act as you would expect a main method to act?



public static void main(String[] args) {
    System.out.println("Main1!");
}

public static void main(String[] someOtherName) {
    System.out.println("Main2!");
}

public static void main(String... args) {
    System.out.println("Main3!");
}

public static void main(String[] args)
  throws Exception {
    System.out.println("Main4!");
}

static void main(String[] args) {
    System.out.println("Main5!");
}

public void main(String[] args) {
    System.out.println("Main6!");
}

public static void main(String args[]) {
    System.out.println("Main7!");
}

public static void main(String[] args[]) {
    System.out.println("Main8!");
}

public static void main(String[][] args) {
    System.out.println("Main9!");
}

public static void main(String args) {
    System.out.println("Main10!");
}

public static void main(String[] args)
  throws IOException {
    System.out.println("Main11!");
}

static public void main(String[] args) {
    System.out.println("Main12!");
}

public strictfp static void main(String[] args) {
    System.out.println("Main13!");
}

void public static main(String[] args) {
    System.out.println("Main14!");
}

public static void main(int[] args) {
    System.out.println("Main15!");
}

public static void main(String[] args) {
    System.out.println("Main16!");
}

public static void Main(String[] args) {
    System.out.println("Main17!");
}


The Answers



/**
 * Fine.
 *
 * This is the most common form of the main method.
 */
public static void main(String[] args) {
    System.out.println("Main1!");
}

/**
 * Fine.
 *
 * This is the most common form of the main method except
 * that the variable accepting command line arguments has
 * been renamed to someOtherName. The name of the variable
 * is insignificant.
 */
public static void main(String[] someOtherName) {
    System.out.println("Main2!");
}

/**
 * Fine.
 *
 * Varargs form of the main method. New with Java 5.
 */
public static void main(String... args) {
    System.out.println("Main3!");
}

/**
 * Fine.
 *
 * This is the most common form of the main method, except
 * that it throws an exception. This is completely valid.
 */
public static void main(String[] args)
  throws Exception {
    System.out.println("Main4!");
}

/**
 * Compiles, but cannot be executed from the command line.
 *
 * Method must be public.
 *
 * Since the signature doesn't match it's a completely
 * different method that just happens to be called main.
 *
 */
static void main(String[] args) {
    System.out.println("Main5!");
}

/**
 * Compiles, but cannot be executed from the command line.
 *
 * Method must be static.
 *
 * Since the signature doesn't match it's a completely
 * different method that just happens to be called main.
 *
 */
public void main(String[] args) {
    System.out.println("Main6!");
}

/**
 * Fine.
 *
 * This is the most common form of the main method
 * except that the square
 * brackets for the String array have been put beside
 * the variable. This is valid, but many think, harder
 * to read.
 */
public static void main(String args[]) {
    System.out.println("Main7!");
}

/**
 * Although the syntax is strange, this compiles, but
 * cannot be executed from the command line.
 *
 * This is the most common form of the main method, but
 * the square brackets for the args array are beside the
 * type as well as beside the args variable. They should
 * be beside one or the other, not both.
 *
 * While I would have guessed that this would not
 * compile at all, it turns out that this is equivalent
 * to main taking a two-dimensional array as a parameter.
 * String[] args[] is the same as String[][] args or String
 * args[][]. While it's certainly valid for a method to
 * accept a two-dimensional array of Strings, this does
 * not fit the required signature for a main method
 * that is to be invoked from the command line. Attempting
 * to execute this will result in the following error
 * message: Exception in thread "main"
 * java.lang.NoSuchMethodError: main
 *
 */
public static void main(String[] args[]) {
    System.out.println("Main8!");
}

/**
 * Compiles, but cannot be executed from the command line.
 *
 * The main() method needs to accept an array of Strings
 * as a parameter. The method below accepts a
 * two-dimensional array of Strings.
 *
 * Since the signature doesn't match it's a completely
 * different method that just happens to be called main.
 *
 */
public static void main(String[][] args) {
    System.out.println("Main9!");
}

/**
 * Compiles, but cannot be executed from the command
 * line.
 *
 * The main() method needs to accept an array of Strings
 * as a parameter. The method below accepts a single
 * String called args.
 *
 * Since the signature doesn't match it's a completely
 * different method that just happens to be called main.
 *
 */
public static void main(String args) {
    System.out.println("Main10!");
}

/**
 * Fine.
 *
 * Throwing a checked exception, like IOException,
 * is legal.
 *
 */
public static void main(String[] args)
  throws IOException {
    System.out.println("Main11!");
}

/**
 * Fine.
 *
 * This is the most common form of the main method except
 * that static and public keywords are reversed. Their
 * order does not matter.
 *
 */
 static public void main(String[] args) {
    System.out.println("Main12!");
}

/**
 * Fine.
 *
 * It's perfectly acceptable to have a strictfp main
 * method.
 *
 */
public strictfp static void main(String[] args) {
    System.out.println("Main13!");
}

/**
 * Does not compile.
 *
 * The return type (void in this case) must come
 * immediately before the method name.
 *
 */
 void public static main(String[] args) {
    System.out.println("Main14!");
}

/**
 * Compiles, but cannot be run from the command line.
 *
 * The main() method must accept an array of Strings,
 * not ints, as a parameter.
 *
 * Since the signature doesn't match it's a completely
 * different method that just happens to be called main.
 *
 */
public static void main(int[] args) {
    System.out.println("Main15!");
}

/**
 * Fine.
 *
 * This is the most common form of the main method
 * except that there aren't any spaces between the
 * type, the square brackets and the variable name.
 * It's still legal.
 *
 */
public static void main(String[] args) {
    System.out.println("Main16!");
}

/**
 * Compiles, but cannot be run from the command line.
 *
 * The main() method must be all lower case.
 *
 * Since the signature doesn't match it's a completely
 * different method that just happens to be called main.
 *
 */
public static void Main(String[] args) {
    System.out.println("Main17!");
}

So why would you want to know so much about the main() method anyway? Well, besides being essential if you’re taking the Sun Certified Java Programmer (SCJP) exam, there are a few alternate formulations of the method that might come in handy. Plus, with the examples above it mind, I bet you’ll spot a flawed main() method quicker than most if you come across one.


Step 1: Open the relevant PDF file and select and copy table

The first page of Table 10 from the Spring 2007 version of the European Economy Statistical Annex is shown below.



To copy the table, click on Select and click and drag the cursor to highlight the whole table. Then press Ctrl C (to copy this).

Step 2: Copy this into Word and convert to a table

Open a new Word document and paste the copied text by pressing Ctrl V. This should look as follows:



Now convert this into a table by highlighting it all (you can easily do this by pressing Ctrl A) and 

For Office 2003
selecting Table > Convert > Text to Table. A dialogue box will pop up and under Separate Text at, you should select Other and click in the little box next to it; delete what is there and type in a space. Press OK.

For Office 2007


















A dialogue box will pop up and under Separate Text at, you should select Other and click in the little box next to it; delete what is there and type in a space. Press OK.






















A table will appear (poorly formatted) which will be all highlighted. While still highlighted, copy this by pressing Ctrl C.


Step 3: Paste this into Excel

Open a new blank Excel document. The first cell should be highlighted. Click in this cell and past in the table you have copied from Word. To do this, simply press Ctrl V. This will give you a table similar to that below.



Step 4: Manipulating the Excel table

You will now need to do a little manipulation. It will help if you have an Insert Row and a Delete Row icon in your toolbar at the top
First ensure that the columns are correctly aligned. In the above, row 5 is one cell too far to the left. To rectify this, click in cell A5 (currently labelled BE). Then click on Insert > Cells > Shift Cells Right and then OK. This will move all the entries in row 5 one column to the right.

Next delete unwanted rows, by selecting the row (click on the row number in the left-hand column) and then pressing the delete row icon (). In the above table you will probably want to delete rows 1, 2, 3, 4, 6 and 7. If you want to work out average inflation rates over the period 1961 to 2008, you will also want to delete all except rows 5, 8, 9, 20, 31 and 40.