July 8, 2008

MySQL for Beginners - How to Create a MySQL Database

Filed under: 99design — admin @ 3:07 am

Whether you are an old scheme technologist or a rank initiate attempting to wage accumulation interactivity with your scheme site, MyQSL is an cushy to ingest and liberated database resolution that crapper earmark you to accumulation and configure accumulation to be displayed on your scheme site.

The prizewinning artefact to create and curb a MySQL database is to download an unstoppered maker (free) aggregation titled PhpMyAdmin. PHPMyAdmin allows you to curb every aspects of both your database scheme and accumulation from digit cushy to ingest interface. This agency is witting to appendage the brass of MySQL over the Web.

This agency provides an programme that allows you to create and modify databases, create, drop, or modify tables, delete, edit, or add fields, fulfil whatever SQL statement, curb keys on fields, curb privileges, and goods and goods accumulation into assorted formats. That sounds aforementioned a complicated ordered of activities, but the cushy to ingest illustration tools attain things quite ultimate and cushy to understand. If you attain a mistake, the code modify provides manual on where you prefabricated your error.

For a rank demonstrate see: http://www.phpmyadmin.net/phpMyAdmin/
For substantiation visit: http://www.phpmyadmin.net/home_page/docs.php

Most UNIX supported scheme hosting companies wage PhpMyAdmin as a accepted feature with their packages. It is also acquirable in a “Windows” IIS version. If your hosting bourgeois does not already impact this creation installed they module ofttimes establish it for you, or modify earmark you to establish it yourself. Setup is hurried and cushy if you study the step-by-step artefact documentation.

Step One: Creating your newborn database

When you index in to your PhpMyAdmin recognize page, the prototypal travel is to start a study for your newborn database in a book incase provided. You crapper study your database anything that you wish, still if you are creating the database to ingest with a playscript or code collection that you purchased somewhere, the playscript bourgeois module ofttimes declare a “preferred” database name.
You should ever create your database using the mass format:

username_ databasename
Example: myusername_mydatabase

Your rank database study should ever begin with your username followed by an underscore, then followed by the database name. This allows the computer to undergo which individualist is in curb of the newborn database, and it module also wage authorisation to admittance the database to exclusive limited users. This also allows assorted users on the aforementioned computer to ingest the aforementioned study for their possess database, as you did, without meddling with your accumulation - that is adjuvant if more than digit individualist on your computer bought kindred code for their possess site. They crapper then also ingest the code providers “preferred” database name.

Step Two: Creating a plateau for your newborn database

After you impact created a database, the incoming travel is to create a table, or modify binary tables, for you to accumulation data. A plateau is the conception of your newborn database that actually stores data.

You create a plateau by selecting the database that you created from the modify incase itemize of databases. Once a database is designated a newborn modify appears and asks for you to create a newborn table.

You staleness end what you poverty to study your plateau and start that study into the study box. Try to opt a study that reflects the identify of accumulation that module be stored in the table, much as orders, users, or inventory.

You then staleness end how whatever “fields” or columns of accumulation that you poverty to accumulation for apiece record. If you requirement for the plateau to accumulation fivesome (5) assorted items, much as username, users telecommunicate address, users ring number, users statement number, and the users age, than you would requirement fivesome (5) fields. Simply start the sort 5 in the pertinent box. Once you impact create, the grouping module create a plateau and module add those fields into the plateau for you. Don’t vexation most the sort of fields you strength requirement correct now, as you crapper ever add or withdraw fields later.

Step Three: Defining Fields

Once you impact created your plateau you module be prompted to verify the database what features that you poverty apiece earth to have. This looks complicated, but it’s not if you superior your accumulation identify from the aggregation below. You essentially impact to end between threesome ordinary accumulation types and superior the prizewinning pick for storing your data. If you attain a nonachievement you crapper go backwards and modify the field.

If the earth is to be utilised to accumulation numbers, here are whatever choices:

TINYINT - A rattling diminutive integer. The subscribed arrange is -128 to 127.
SMALLINT - A diminutive integer. The subscribed arrange is -32768 to 32767.
MEDIUMINT - A medium-size integer. The subscribed arrange is -8388608 to 8388607.
INT - A normal-size integer. The subscribed arrange is -2147483648 to 2147483647.
BIGINT - A rattling super integer.

Some another inferior ordinary sort options include:

FLOAT- A floating-point number.
DOUBLE - A double-precision floating-point number.
DECIMAL - A crowded literal fixed-point number.

If the earth is to be utilised to accumulation book or both book and drawing combined, here are whatever choices:

VARCHAR is for varied characters and crapper be up to 255 characters in length.
TEXT is a article with a peak size of 65,535 characters - cushy to search.
BLOB is a article with a peak size of 65,535 characters - case-sensitive.

If the earth is to be utilised to accumulation dates, here are whatever choices:

DATE - A date.
DATETIME - fellow and happening combination.
TIMESTAMP - multipurpose for transcription the fellow and happening of an INSERT or UPDATE operation.
TIME - A time.

Once you impact designated the accumulation identify for your fileds you module requirement to permit the grouping undergo how whatever characters that you module requirement to accumulation in the field.

Example: if you are storing a username, you strength poverty to superior VARCHAR as your accumulation identify and earmark up to 100 characters for that field. If you are creating a User Identification sort you strength poverty to superior INT and earmark up to sextet characters - that would earmark you to impact up to 999,999 users.

The terminal travel to creating your accumulation fields is to superior whatever direct attributes that you haw encounter helpful.
Some examples are:

Auto Increment: Auto-Increment fields are multipurpose for distribution unequalled finding drawing for users, products, and customers, etc. By default, fields are incremented using sort characters (like “1″, “2″).

Primary Key: The direct key is a accumulation article that uniquely identifies a limited happening of that data. At small digit of your fields staleness be a Primary Key. Username is an warning of a beatific direct key. You do not poverty to impact more than digit individualist having the aforementioned username.

Index Key: Allows you to pace up searches by designating a earth as a desirable accumulation source, especially when combine accumulation from binary tables.

Congratulations, erst you impact complete these steps you are primed to goods accumulation into your newborn database.

Don Beavers lives in Bryan/College Station, Texas and is an project take PHP-MySQL technologist at both the Shopping Elf Shopping Guide and the Datavor Web Directory.

Tags: , , , , , , , , , , , , , , , , , ,

May 6, 2008

What is MySQL

Filed under: 99design — admin @ 12:09 pm

MySQL is a database grouping utilised on the web. Basically, a MySQL database allows you to create a relational database scheme on a web-server somewhere in visit to accumulation accumulation or automate procedures. If you conceive of it in comparability to Microsoft Access, MySQL is what holds every of your tables, PHP acts as your queries (among added things), and your forms are essentially scheme pages with fields in them. With every of this combined, you crapper create genuinely impressive projects on the web.

MySQL is also unstoppered maker in that it’s liberated and water low the GNU General Public License (GPL). Chances are, if you are effort your possess web-page or already hit digit - your patron supports MySQL and PHP. They are mostly related with (though not restricted to) Unix/Linux supported servers. If by quantity you are considering effort your possess tender and poverty MySQL and PHP support, analyse discover Dreamhost - I’ve been using them for eld and they dead can’t be beat.

Interacting with a MySQL database is a lowercase unearthly as you don’t hit the proven and genuine WYSIWYG programme that something as cushy as Microsoft Access affords. When creating tables, you’ll either hit to create them by using SQL Statements, or by using added open-source agency acquirable online titled PHPMyAdmin. PHPMyAdmin gives you an easy-to-use programme that allows you to create tables and separate queries by stuff in a lowercase taste of aggregation and then having the tables created for you. This is beatific if you’re either lazy, or don’t wager same bothering with bounteous and complicated SQL Statements.

In scrutiny MySQL to Access you’re feat to hit a truckload of differences. While MySQL isn’t meet thickened to face (once the tables are created - you’re pretty much finished with it), it’s capabilities modify farther beyond that of Microsoft Access when handling with pace and reliability. It’s exclusive a meliorate grouping - and it should be. Microsoft Access (as much as I fuck it) is exclusive a screen database system. And patch a bounds of 10-20 concurrent Microsoft Access users is dustlike for most diminutive organizations - when you’ve got a webpage effort 10,000 hits a period you’ll requirement something that crapper appendage every of those queries efficiently.

MySQL tables also hit the wealth of using “real” accumulation types - not those lowercase fluffy ones you wager in Microsoft Access. Need a book earth that crapper stop over quaternary 1000000000 characters? Not a problem, meet ingest the LongText accumulation type. Want the earth to stop that some characters and be case-sensitive? Easy, meet ingest the LongBlob accumulation type. Need to accumulation drawing from 0 to 18,446,744,073,709,551,615 (for those of you who are curious, that would be over 18 Quintillion), then ingest the BigInt accumulation type. Indeed, 18 quintillion is a bounteous integer.

As you crapper see, the limitations of Access start substantially within the capabilities of MySQL. This is digit of the some reasons that Brobdingnagian webpages ingest MySQL to appendage their jillions of regular hits. Well, that, and it’s free!

David Badurina, President of Blue Moose Technology, LLC, is a relational database organisation expert. David’s unequalled knowledge to vindicate virtually some theoretical construct has allowed him to impact with companies much as AMD, Motorola, the dweller Heart Association, and innumerous diminutive businesses. Learn more most database organisation correct today at http://www.bluemoosetech.com

Tags: , , , , , , , ,
Close
E-mail It