PostgreSQL & PHP Tutorials - Introduction to Databases - Step 1

PostgreSQL »  Introduction to Databases
PostgreSQL »  Starting Out »  Introduction to Databases

Posted By Chris Smith Posted on 07 Feb 2006, 05:29 AM
Viewing page 1 of 3
« | Back | Next | »

Databases are used every day, sometimes without us realizing. They are everywhere. The most basic example is a telephone book or a library card index. They can store all sorts of information, from phone numbers to map grids and references, score cards from sports games, report cards, etc. They allow quick searching and are great for keeping historical data, for example weather history. Most websites run using a combination of a database and a CMS (content management system).

At the most basic level, databases contain tables. Database tables are used to hold information, for example you may have a database table about 'authors' or 'news'.

Inside a table, you have fields. Table fields tells us what information is being kept in the database. In an authors table, for example, you may keep the persons name and email address.

The actual data is kept in rows.

The layout of a database table, fields and rows looks much like a spreadsheet in grid format.

A whole database is a number of spreadsheet pages all linked together in a particular way.

Databases allow adding, deleting, updating and retrieving of data quite easily, as well as sorting and searching.

Database design can be quite tricky and time consuming, so before you start anything you need to think about what you're trying to do and exactly what you want to achieve.

Using a CMS as an example, we'll look at some of the basic features and see how to put a database together. This process doesn't just apply to a CMS design, it applies to any type of application that uses a database. Some things of course apply to any application you want to build, whether it uses a database or not.

The first step is to get a list of features together so you can see what you need to think about.

- Do you want many authors or contributors to your site (or is it just you writing everything)?
- Do you want just a news section, or do you want blogs as well?
- Do you want different categories?
- Do you want people to write comments?


Now that you have a basic feature list, you can look at how things fit together so you can design your database. Each step will affect other steps, so it's important not to rush designing your database - it can be very difficult to "fix" it later and could end up being quite costly too!

In this example, you have different categories so you can group your content together (a sports site might separate popular sports like football, baseball, basketball and so on).

You also have a news area.

At the basic level, news will have a title and the actual content. Looking at extra features you might want to include:

- Will news items be in multiple categories or will they only be allowed in one particular category?
- Will multiple authors contribute to a news item or will it be just one?
- Will news need to be authorised before going live?
- Will news expire after a certain amount of time?
Avg Rating: 3
Vote Count: 2


              


Want to post a comment? Fill in the details below.

Your Name  : 
Your Email  : 
Your Website  : 
Spam Check! Please answer this question  : 7 + 3 =
Comment