Okay....so you have no database layout at all so far?
In that case, you'll want to do it a piece at a time. Hopefully by the time you're past piece 1 or 2 then you'll have a better idea of the what exact questions you'll need to ask.
First, start with the registration piece. You'll need one of these to get your users set up so it's a sure-fire necessity and thus one of the best places to start.
You'll need to figure out what information you want to store in your Users table and then translate those into columns.
For instance, you'll need User Name, Password, Email and probably First Name and Last Name so let's mock that up.
Code:
CREATE TABLE USERS
( ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
USER_NAME varchar(25) NOT NULL DEFAULT '',
PASSWORD varchar(25) NOT NULL DEFAULT '',
FIRST_NAME varchar(150) NOT NULL DEFAULT '',
LAST_NAME varchar(200) NOT NULL DEFAULT '' )
(this is written for a MS SQL Server database.....if you're using mySQL then you will want to research the correct syntax for that. Or, you can always use the GUI Front end for your Database to create the tables)
What we have there is an ID which will just be an increment integer value (1,2,3,4.......). When referring to users from other tables, you'll want to use this.....Integer-based searches are much faster than character-based. Storing the value '1' 1000 times is also much better on your storage than storing 'guest'.
The following columns are all pretty straight forward. One thing you might not notice in other people's examples on the web is that I force all my columns to be NOT NULL and supply a default value of '' (empty string). A very often overlooked performance tweak to any database is to not ever use NULLs when you can get around them. They cause overhead and for almost all varchar fields, the empty string works just as good.
Okay, so we have your users table.....let's whip up another sample table so you can see how we use that ID field from the USERS table and I can show you how to use a View to pull the information all together.
Let's say you want a separate table to store users' avatars.
Code:
CREATE TABLE AVATARS
( ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
AVATAR_FILE_NAME varchar(500) NOT NULL DEFAULT '',
USER_ID INT NOT NULL DEFAULT 0 )
So, if we had the following user entries....
Code:
ID USER_NAME PASSWORD FIRST_NAME LAST_NAME
1 rthomas ****** Rob Thomas
2 bspears **** Brittney Spears
....then we could expect to see Avatar rows like this....
Code:
ID AVATAR_FILE_NAME USER_ID
1 c:\I_am_washed_up.jpg 2
2 c:\I_am_awesome.jpg 1
You should be able to use those USER_ID values to figure out whose Avatar is whose.
And...now that I think of it...there's a sticky in the Database section here that I think has a guide to Views that I wrote....check it out to see how to tie those tables together into one query.