Jump to content

Relational Database


legacy800

Recommended Posts

Hello,I have tried searching for "Relational Database" to try and find some info about how to make such a database with phpMyAdmin, but information about this seems to be a bit rare to find even on these forums.Maybe im searching for the wrong thing, but to explain why I want to use this.I want one table with the row games and a primary id row linked to another table wich holds multiple images for each game.This way being able to select a game and displaying all the images that go with that particular game on a page with php.Structured something like:Tables Games:GameIDGamesGenreTables Images:ImageIDGameIDImagesI did read something about innoDB, maybe somebody has a tutorial on this.Only problem was I did find some tutorials but im very new to this so it needs to be understandable for a beginner.Greetings,Legacy

Link to comment
Share on other sites

If you really want the database to enforce that rule, then you do need to create the tables using the InnoDB storage engine, and you can create a foreign key relationship between the two tables. phpMyAdmin doesn't have a button for creating a foreign key (as far as I know), so you'll need to use a SQL statement to define that.Most web applications using MySQL do not have the database enforce these constraints, instead the application itself checks for that (e.g. when you delete a record from the games table, you would also delete all associated records from the images table).http://dev.mysql.com/doc/refman/5.1/en/inn...onstraints.html

Link to comment
Share on other sites

check out this link:http://www.mytechmusings.com/2008/04/using...s-in-mysql.htmlits a video tutorial on creating FK's through phpmyAdmin. Basically you first change the db engine for tables that have a relationship to the InnoDB engine. Then you go to the Structure tab, and click the 'index' button on the field that will be a FK. Then you scroll down and click on Relation View and thats where you can specify the relationship.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...