Jump to content


This topic is now archived and is closed to further replies.


Database Structure help

Recommended Posts

I'm finally get a grip on using databases in my scripts, but I'm still lacking a bit in exactly how best to construct my databases ... so I'm hoping that I might be able to get some help with that here  ;)

I currently have a MySQL database with one table called "users." In it will be held the registration information for everyone who signs up to the site: username, password, date of registration etc. etc.

Now I want to link that table with another table that will contain information regarding the car that the user drives. This information will be collected from a second form and will contain data such as type, make, year of construction, colour etc. etc.

What's the best way of linking these two tables together in order to help with running searches or scripts in the future? I was planning on inserting the relevant username into the second table as well so that I can run searches across both tables ... but is that the best way of doing it?

Thanks alot for your help

Share this post

Link to post
Share on other sites
  uid INT(20) <--- Primary Key
  name_f VARCHAR(32),
  name_l VARCHAR(32),
  passwd CHAR(32), <-- Assuming your using MD5() encryption
  reg_date DATETIME,
  ... anthing else you need

  vid INT(20) <--- Primary Key
  uid INT(20) <--- User the Vehicle Belongs To (index this for searching purposes)
  make VARCHAR(20),
  model... etc...

If you wanted to... (efficiency wise), set the make and model to type integer (isntead of string) and link them in there own table. It might be easier to maintain down the road...

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.