MortimerJazz Posted August 8, 2006 Share Posted August 8, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/16883-database-structure-help/ Share on other sites More sharing options...
lead2gold Posted August 8, 2006 Share Posted August 8, 2006 [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... Quote Link to comment https://forums.phpfreaks.com/topic/16883-database-structure-help/#findComment-71103 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.