mercredi 17 février 2021

derby database with 2 linked tables

I'm working on a photo collection app, coded in java and using derby for storage. The idea is that there will be a file system view of the collection and also a category based view. Each photo will be in one or more (probably less than 5) categories and each category might hold hundreds of photos.

So I've come up with ideas for my tables:-

photo

id INT(5000)    
file_path TINYTEXT(100) 
categories foreign key(s)

category

id TINYINT(50) 
name    TINYTEXT(30)
photos foreign key(s)

But how to allow each photo id several categories and each category id many photos? What's the recommended way of doing this?

Aucun commentaire:

Enregistrer un commentaire