Loading...
  Lost your password? Lost your Username? Make a new account!  
Warez Home  
FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Go Back   Warez Home > Databases

Databases Using a database to store your website's data? Learn about common issues and pitfalls, the correct use of indexes, normalisation and much more.


Reply
 
Thread Tools Display Modes
Old 03-11-2010, 11:11 PM   #1
wisam
Administrator
 
Join Date: Nov 2006
Posts: 164,690
Lightbulb Having Problems with Databaase Design

Hello everyone,
I have a database design as follows:

CREATE TABLE users (
user_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
username VARCHAR(30) NOT NULL,
password CHAR(40) NOT NULL,
firstname VARCHAR(20) NOT NULL,
lastname VARCHAR(40) NOT NULL,
acct_type VARCHAR(20) NOT NULL,
company VARCHAR(40) NOT NULL,
email VARCHAR(80) NOT NULL,
reg_date DATETIME NOT NULL,
PRIMARY KEY (user_id),
UNIQUE(username),
INDEX(password, username),
UNIQUE(email)
);

CREATE TABLE messages (
-> message_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
-> forum_id TINYINT UNSIGNED NOT NULL,
-> parent_id INT UNSIGNED NOT NULL,
-> user_id MEDIUMINT UNSIGNED NOT NULL,
-> subject VARCHAR(100) NOT NULL,
-> body LONGTEXT NOT NULL,
-> date_entered TIMESTAMP NOT NULL,
-> PRIMARY KEY (message_id)
-> );

CREATE TABLE images (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
filename VARCHAR(255) NOT NULL,
mimetype VARCHAR(50) NOT NULL,
description VARCHAR(255) NOT NULL,
filedata MEDIUMBLOB
);

CREATE TABLE user_images (
user_id MEDIUMINT(8) UNSIGNED NOT NULL,
id INT(11) NOT NULL,
PRIMARY KEY (user_id, id)
);

CREATE TABLE forums (
forum_id TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(60) UNIQUE(name)
);

The point here is:
1) user_id in the users table is linked to the messages table and user_images table.
2) 'id' in the user_images table is linked to the images table
3) messages table is linked to the forums tables using the forum_id

NB: The user_images table is ment to be a look up table so that when a user with
acct_ type designer is logged into the site, he can upload images via this user_images table.

Secondly, parent ID is used to track a reply to the same subject in the messages table.

Summary:
What I am trying to design is a database where users(who are designers) register into my website whose details are stored in the users table and the login to upload images onto the website.

I am not sure if my design is right and the main issue is how to upload images into the database once a user is logged in.
Thanks.
ncax2
wisam is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Still having problems... wisam .NET 0 11-29-2009 06:43 AM
Having Problems wisam Social Networking and Communities 0 08-22-2009 07:30 AM
NorHayer Design website design, graphic design, forms, hosting, domain, etc wisam Graphics 0 08-18-2009 08:52 AM
NorHayer Design website design, graphic design, forms, hosting, domain, etc wisam Web Page Design 0 08-18-2009 08:52 AM
LOGO DESIGN for my web design company... How important is it? wisam Promotion Techniques 0 05-28-2009 03:41 PM


eXTReMe Tracker
 
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
   
All times are GMT. The time now is 06:22 AM.  
 
Style by MafiiOso