I asked this on another forum but I don't seem to be getting an answer I can understand.
From what I have read you can't use foreign keys in mysql and was told indexing what would normally be a foreign key would do the job.
I really don't see how this can work as when I index how does it know that the primary key is where it should get its data?
Here's the original question:
I have two tables one with user info inside it and one with details about images uploaded, obviously when a user logs in I want to pull the user data from the user table and the related user picture from the picture table. Best way I presumed to do this would be to use a foreign key like so.
User Table...........ImageTable
ID......................ID
Name..................Location
DOB...................Size
etc...
Obviously ID is primary in User table and foreign in Image Table. ID in user table auto increments every time somebody signs up. At the moment ID in ImageTable is empty.
From what I have read you can't use foreign keys in mysql and was told indexing what would normally be a foreign key would do the job.
I really don't see how this can work as when I index how does it know that the primary key is where it should get its data?
Here's the original question:
I have two tables one with user info inside it and one with details about images uploaded, obviously when a user logs in I want to pull the user data from the user table and the related user picture from the picture table. Best way I presumed to do this would be to use a foreign key like so.
User Table...........ImageTable
ID......................ID
Name..................Location
DOB...................Size
etc...
Obviously ID is primary in User table and foreign in Image Table. ID in user table auto increments every time somebody signs up. At the moment ID in ImageTable is empty.
Last edited: