MySQL for Beginners - How to Create a MySQL Database
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: data base, Database, databases, design, MySQL, PHP, phpmyadmin, SQL, tutorials.programming, web developement