Dysan Posted March 16, 2008 Share Posted March 16, 2008 Hi, Using PHP & MySQL, how does one create a relational database? Quote Link to comment Share on other sites More sharing options...
Dysan Posted March 16, 2008 Author Share Posted March 16, 2008 How do I convert the following database into a relational database? The database contains peoples favorite food and drinks. if (mysql_query("CREATE DATABASE db",$con)) { echo "Database Created!"; } else { echo mysql_error(); } mysql_select_db("db", $con); $sql = "CREATE TABLE persons ( name text, )"; mysql_query($sql,$con); $sql = "CREATE TABLE items ( favouritedrink text, favouritefood text, )"; mysql_query($sql,$con); mysql_close($con); Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 16, 2008 Share Posted March 16, 2008 ad an id field on your person table, id int unsigned autoincrement primary key. then add a field on the items table called person_id int unsigned. relate the tables together by including the id of a record in the person table as the person_id for a record in the items table. 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.