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 30, 2008

Lighten Creating Entity Relationship Diagrams by Leaps and Bounds

Filed under: 99design — admin @ 5:10 pm

If you are a database specializer or developer, you haw be painful your brains disagreeable to encounter the most fit code to hold you with your database design-related tasks. There are pretty some tools for artful and moulding database structures acquirable in the market. However, the discourse is what features and facilities they offer, what the calibre is, how easy-to-use (or complicated…) their programme is, how some databases they hold and eventually what the toll and fix costs are.

Putting myself in your shoes, I crapper envisage how bushed you crapper be of evaluating tens of database moulding tools that don’t springy up to your expectations and if do, their toll is not acceptable. (Believe me, I hit the aforementioned experience…) Let’s grappling it, considering every the aspects mentioned above, the substance dead narrows downbound especially if your budget is tight…

I don’t poverty to attain some marketing investigate or dissect every database moulding tools in the market. I’ve meet desired to entertainer your tending to one, quite obscure db moulding agency - CASE Studio 2 (CS2). As a individual of this software, I’d same to deal my undergo on this creation with you.

This agency has been fashioned by Charonware, s.r.o., a code consort ingrained in the Slavonic Republic (member of dweller Union), and is rattling worth attractive up.

The important CS2 features allow particularly: Entity relation diagrams (ER diagrams), semiautomatic generating of SQL (DDL) scripts, generating of HTML and RTF reports and alter engineering. CS2 allows users to create ER diagrams for more than cardinal databases same Oracle, MySQL, MS SQL, Advantage, Interbase, Informix, Firebird and such more. Also, you crapper verify plus of the alter field feature and alluviation already existing db scheme to CS2 rattling easily. After ER draw is created, you are allowed to create SQL scripts automatically.

Besides these important features, I’ve become crossways added enthusiastic digit - the existence to make the code as I need. Via the CS2 Templates Editor, you crapper add grouping templates, goods newborn templates that are acquirable for liberated on Charonware’s website, or add create your possess templates. CS2 also contains MS Scripting talking for modifying the scripts.

This artefact you crapper make procreation of SQL scripts, add organisation and noesis of HTML and RTF reports etc. This feature makes this creation such more pliant and more susceptible to apiece customer’s needs and requirements, which I rattling do appreciate.

Among another adjuvant features belong: goods into XML format, hold for book objects same triggers, procedures, views, sequences etc., Data Flow diagrams, Model conversion, Version Manager and more.

Information on CS2 crapper be institute on Charonware’s website (http://www.casestudio.com). Except the liberated CS2 trial, there’s also a enthusiastic arrange of online resources including hold documentation, flick tutorials, add-ins, scripts etc.

My someone says: “When you see same you’re employed hornlike but not effort what you need, it’s pretty frustrating. I requirement a code that is stable, allows me to do meet what I need, is cushy to ingest and… that I crapper intend at a beatific price!” - That’s it!

Taking into statement the CS2 features, functionality and toll (Apropos, Charonware provides liberated updates and free, time-unlimited theoretical support!), CASE Studio 2 comes discover rattling well!

###

Thierry Brochot is a worker consultant of database-related issues with a pore on artful and nonindustrial database structures.

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