The Woork Handbook

Page 66

T H E

W O O R K

H A N D B O O K

v

0 . 1

id_site_pk INT NOT NULL AUTO_INCREMENT, site_url VARCHAR(250), site_description LONGTEXT, site_data_reg DATA, PRIMARY KEY ) TYPE=INNODB"; mysql_query($sql); $sql="CREATE TABLE SHARE ( id_share_pk INT NOT NULL AUTO_INCREMENT, id_user INT NOT NULL, id_site INT NOT NULL, submitted_by INT NOT NULL DEFAULT 0, PRIMARY KEY (id_share_pk), FOREIGN KEY (id_user) REFERENCES USER(id_user_pk) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (id_site) REFERENCES SITE(id_site_pk) ON UPDATE CASCADE ON DELETE CASCADE ) TYPE=INNODB"; mysql_query($sql); // Close Connection mysql_close($db_con);?>

Now save the file and test it on your localhost. In this way you can reuse create_database.php to copy your database structure on remote server when our project is ready to be published. ______________ ★ ORIGINAL POST

http://woork.blogspot.com/2007/10/project-database-how-to-use-php-andsql.html

2.4. Create relationships between database table using phpMyAdmin I dedicated already some post about how to design and develop a database, but some readers asked to me to explain how to define relationships in a database and a correct approach to create them.

66


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.