Introduction To Databases

Introduction To Databases
One of the greatest features of PHP is how well it works with databases. But many people are intimidated when they begin working with databases. However a database is really just a bunch of data stored in a logical order. You can store any type of data in a database. You can store information about your business customers or the scores for your bowling league. But how do you keep your customer data separate from your bowling scores?

Databases are made up of a bunch of tables that contain the information you wish to store in your database. You can have as many tables as you want in your database. Each table will contain the information about a different topic. So you can store your customer information in one table and the bowling scores in another table.

Let's say you want to store the following information about each of your customers.

John Doe
5555 Happy Street
P. O. Box 555
Columbus, Ohio 55555
Jane Smith
5555 Read Road

Cleveland, Ohio 55555
Mary Scott
5555 Happy Lane

West Lafayette, Indiana 55555


Let's put this information into a table.

John Doe
Jane Smith
Mary Scott
5555 Happy Street
5555 Reed Road
5555 Happy Lane
P. O. Box 555Columbus
Cleveland
West Lafayette
Ohio
Ohio
Indiana
55555
55555
55555


As you can see, each customer's information is all on one line in the table and the information fits nicely into individual columns in the table. This makes it easy to access just certain information about your customers such as just their zip codes or just their names.

Next we need a way to identify the information stored in each of these columns in our table. So let's give each column a name.

customer_name
address_1
address_2
city
state
zip

Let's add these column names into the table.

customer_nameaddress_1address_2citystatezip
John Doe
Jane Smith
Mary Scott
5555 Happy Street
5555 Reed Road
5555 Happy Lane
P. O. Box 555Columbus
Cleveland
West Lafayette
Ohio
Ohio
Indiana
55555
55555
55555


That's the basic idea of a database. You would have a column, called a field, for each individual piece of information you want to access such as zip codes or names. Each customer's information is all on one line in the table, called a record, so it is easy to match the information to the customer. And there is a different table for each individual topic, customers or bowling scores.






This site needs an editor - click to learn more!



RSS
Editor's Picks Articles
Top Ten Articles
Previous Features
Site Map





Content copyright © 2023 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.