Jump to content


Photo

Database Structure help


  • Please log in to reply
1 reply to this topic

#1 MortimerJazz

MortimerJazz
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts
  • LocationBedfordshire

Posted 08 August 2006 - 10:58 AM

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

#2 lead2gold

lead2gold
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts
  • LocationOttawa, On

Posted 08 August 2006 - 12:47 PM

users{
   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
}

vehicle{
   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...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users