Tuesday, March 20, 2007

Free Tutorial - Build a website v1.0 part 1 - Adding a database and table into MYSQL

To add a database in your new MYSQL server, you need to go to http://localhost/phpmyadmin/ Here you will be able to login using you user+password that you created in the previous tutorial.

Here you can find the: Somewhere in the middle of the page. For example, name your new database: my_database, and hit the create button.

Voila! you've just created a database. Your first database! wasn't that hard was it?
ok. now for the tables....
there is a Create new table on database my_database somewhere in the page right afther you created the database. there you can add a table name and the number of Fields.

The number of fields is important but can be changed from settings while you are givving specific names and attributes to the fields.

Now... .let's make a table named users with 5 fields.

you maybe wondering why 5.... well.... because I say so!..... :)....ok..no...actually...it's because I want to add An ID, a user first name and a last name (separate) and the user age and description. 5!


why all these? because I want to make them of different types.

Hit GO and shut up!

The ID is the unique identifier. It is very recommended that an ID should be created in any table. IT is a unique number that auto-add's 1.....or.....act's like +1 each time a new field is inserted into the database.

to create an ID, let's:
~ type in the first field textbox the name : ID
~ select from the same row the type of INT from the dropdownbox
~ write the value of 9 in the Length/Values Section
~ From the EXTRA dropdownbox select the auto_increment value
~ Click the radobutton on the same row where there is a key (primary key if you hold mouse over radiobutton or icon)

and....fwew!!! ID is created.

You must select from the EXTRA and the primary key only for the ID button.
the rest of the fields will just make the first 3 steps....with minor modifications.

The second row let's type in the field: first_name
Select the varchar from type and write 121 in the lenght
next row, same thing except for the field , where u write last_name
in the next row, write age, select int again from type and write 3 in lenght
Last row, write description in field, select text and don't write anything in lenght

not...to explain....

darn! I was hoping that it would of been over by now too.. :(.....hold on to your .......hat!
here we go....

the INT is an integer...meaning numbers and the lenght is the ....well...lenght of the field
for example..if I add 3 as lenght, I can only insert into that table and field numbers between 0 and the maximum 3 digit number (999)... u get the ideea...

VARCHAR is a character type.... I can add as many characters as I want..but...there is a limit!
This is important when doing searches and queries later (the big programming starts there)

TEXT is a infinite VARCHAR.....no restrictions....add your book or something,....


hmm.....
questions?
no?
yes?

Done!
Bye!
see u later!
hope it helped!
thanks for watching!
arrivedercy
come back soon
gtg
keep in touch

ciau!

cy21

1 comment:

Anonymous said...

Very good tutorial ! I like it because I'm beginer only. : >

Keep it up!