Simon wrote:
> I am I correct in saying - if I am only person inputting data and make sure that I do not enter
> into the Images table a Property ID that does not exist in the Properties table, I could get by with
> just the 2 tables Properties & Images, as I do not need to have the Integrity checked?
No, that is not correct. A third table is necessary to model the many-to-many relationship between properties and images. Suppose you would add a foreign key property_id to the images table.
With the statement:
INSERT INTO images (id, path, property_id) VALUES(NULL, '/some/directory/image1.jpg', 1);
you would record that image.jpg is about the property with id = 1.
Now suppose image1.jpg also shows the property with id = 2. To record this, you would have to add:
INSERT INTO images (id, path, property_id) VALUES(NULL, '/some/directory/image1.jpg', 2);
The problem with this is that you have duplicated information. If you move image1.jpg to another directory e.g., you have to UPDATE several records.
With the three table model, you only have to update one record.
--
felix
Please use
BBCode to format your messages in this forum.