mysql - Managing picture tags in SQL -


I want to create a database of images. Each image can contain 1 or more tags, for example: Paris , April 2010 , David .

How do you store this information? I have been treated as a file table with one row per file, and one of the tags in the column will be the tag IDs separated by commas, for example: 2,4,14,15

In the other table named tag , I thought 1 row per tag, like this:

  Tag ID Tag Name -------- ----- April 1, 2 David 3 Paris  

Do you think managing such a tag is a good idea? For example, how do I easily get all tag names of specific tags?

You must have 3 tables, tags, and file tags.

File tags should contain file IDs and tag IDs. One line for one tag assignment.

Then you can easily query all the files with a certain tag:

  Select different options. * Connect the files to fgettag on filetag. File edit = FTIIID is included in the tag t on ft.TagID = t.TagID where t.agName = 'Paris'  

or all tags for any file:

< Pre-> select from a different type of code> ftileID = ft.FileID to the file tag feeds. Add tag to ft.TagID = t.TagID t where f.FileID = 7

Comments