FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


all about database development





macky
hi guys.. i'm wondering were to begin to create my own database.

I currently planning to develop my own site and i figure it out that i should first do the database before programming it. The main problem is, i don't have any idea how to begin my database structure. And most main problem is how to avoid redundancy and making it normalize...

thanks..
Fire Boar
Well... I always say the best way to think of a database is as a program in its own right, and an object-oriented one. The idea of a database is to store the "state" of your program, so mapping it exactly to your program structure has merit. So, here are the analogies:

Database = Program
Table = Class
Field = Class property
Row = Object

As an example, let's suppose you have a Page class. For - say - some content. In PHP your class might look like this:

Code:
class Page
{
  protected $content_id;
  protected $title;
  protected $teaser;
  protected $body;
  protected User $owner;
}


This corresponds to a database table like this:

Code:
CREATE TABLE page (
  id INT(11) AUTO_INCREMENT PRIMARY KEY,
  title VARCHAR(255),
  teaser TEXT,
  body TEXT,
  owner INT(11),
  CONSTRAINT f1 FOREIGN KEY (owner) REFERENCES user (id)
);


The "user" field is a foreign key referencing the id column of a user table (which I'm just assuming exists here).


That's the basic gist of it. Reading up on classes, SQL and database normalization is a good idea.
Related topics
WTF! A strange database just appeared lol
script backup database
A "small" list of free apps
How much database
database problem
Interview: Derek Liu, Gaia Online Anime Community
Implementing your database access in PHP as a layer.
New CMS - ToendaCMS - No database necessary!
What lanugage should I learn next?
Database connection class!
Making Application Portable
What is the best Browser independant development environment
PHP on server without database
[Bug | Improvment ] FriHOST Main Page | Game Development S.
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.