I am trying to make a database for stock data in web2py like, Company A holds data for equity in 2010, 2011, 2012... and Company B holds data for equity in 2010, 2011, 2012... This is what I come up with.
db.define_table(
'company',
Field('name'),
format = '%(name)s')
db.define_table(
'years',
Field('fiscal_year'),
format = '%(fiscal_year)s')
db.define_table(
'stock_data',
Field('company_id', db.company),
Field('years_id', db.years),
Field('equity', 'integer'),
format = '%(equity)s %(years_id)s -> %(company_id)s')
db.company.name.requires = IS_NOT_IN_DB(db, 'company.name')
db.years.fiscal_year.requires = IS_NOT_IN_DB(db, 'years.fiscal_year')
The problem is that I can repeat the same year for a company many times with different values. How can I "link" a year to a company and the equity value for that year.