Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/16883-database-structure-help/
Share on other sites

[code]
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...
}
[/code]

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...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.