I have a table of articles in my web2py project similar to this one:
db.define_table('articles',
Field('created_on', 'datetime', default = datetime.today(),
required = True, notnull = True,
requires = [IS_NOT_EMPTY(),
IS_DATETIME(format=T('%Y-%m-%d %H:%M:%S'))]),
Field('article_en', 'text', required = True,
notnull = True, requires = IS_NOT_EMPTY()))
and another one which keeps track of uploaded files:
db.define_table('files',
Field('filename', 'string', required = True, notnull = True),
Field('uploaded_data', 'upload', autodelete = True,
required = True, notnull = True, requires = IS_NOT_EMPTY()),
Field('created_on', 'datetime', required = True, notnull = True))
Now I would like to have references for every file an article uses, and references for every article to which a file belongs. I need this so I can easily delete unused files without the danger of messing up articles because of overlooked relationships.
To put it more straightforward the relationship is something very close to this: every article has several files and every file links to different articles.
From what I gathered from the web2py book there is no direct support for many-to-many relationships. In order to solve this issue a simple workaround would be to use an intermediate table dealing with the relations but obviously I am not a database guru so I have little to no idea how I should do it.
Some help would be greatly appreciated!