Cassie_au Posted May 11, 2008 Share Posted May 11, 2008 hey guys!! found this forum while looking for help :s im currently doing an assignment for school with php and mysql. i need to setup some tables for items in a shop, however i need to include foreign keys. could anybody give me any ideas as to which table fields would link to what? (as an example) thanks in advanced guys! Quote Link to comment Share on other sites More sharing options...
mezise Posted May 11, 2008 Share Posted May 11, 2008 I recommend reading some tutorials eg: http://www.1keydata.com/sql/sql-foreign-key.html Quote Link to comment Share on other sites More sharing options...
Cassie_au Posted May 12, 2008 Author Share Posted May 12, 2008 hey mezise! thanks for the help! that actually answered a lot of my questions! however ive come across another prob: im making a table for members when they sign up. i have a field for Date of Birth, what field type should it be? DATE? thanks again guys! Quote Link to comment Share on other sites More sharing options...
mezise Posted May 12, 2008 Share Posted May 12, 2008 ... i have a field for Date of Birth, what field type should it be? DATE? Yes, DATE. Quote Link to comment Share on other sites More sharing options...
Cassie_au Posted May 12, 2008 Author Share Posted May 12, 2008 Hey thanks again mezise! sorry my questions must sound so dumb to yous. i have to make an 'orders' table also. besides: id, date, customer_id, and amount fields, shouldn't there also be a field for the product(s) theyre ordering? and what if there's more than one product? thanks in advanced! Quote Link to comment Share on other sites More sharing options...
mezise Posted May 12, 2008 Share Posted May 12, 2008 Add table PRODUCTS(id, name) and table ORDERS_PRODUCTS(order_id, product_id). Quote Link to comment Share on other sites More sharing options...
Cassie_au Posted May 12, 2008 Author Share Posted May 12, 2008 Add table PRODUCTS(id, name) and table ORDERS_PRODUCTS(order_id, product_id). hi! should product_id be a foreign key with PRODUCTS.id? and what would happen if there is more than one item in the order? thanks mezise! Quote Link to comment Share on other sites More sharing options...
mezise Posted May 12, 2008 Share Posted May 12, 2008 should product_id be a foreign key with PRODUCTS.id? Yes, correct, as the name suggests (I thought it was obvious). and what would happen if there is more than one item in the order? ORDERS_PRODUCTS will be filled with first record with appropriate order_id and product_id and every next record with the same order_id and succeeding product_id. Quote Link to comment Share on other sites More sharing options...
Cassie_au Posted May 13, 2008 Author Share Posted May 13, 2008 Thanks a lot Mezise! you've been a great help! Quote Link to comment 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.