this is probably a really really simple question but shamefully it's had me stumped for a while. I am building a simple application which would allow users to purchase Newspaper Articles. Simple enough but the relations is killing me.
I'll outline my goal and where I am so you get an idea of my thinking and perhaps can point me in a more logical direction if needed.
So the way I see it, I have 3 entities.
An Author, An Article and A Reader
An Author can have many Articles
An Article can have one Author
An Article can have many Readers
A Reader can have many Articles
An Author and a Reader have no relation
Mapping a new Article to an Author is not a problem and I have this working
My problem is with mapping many Articles with many Readers
I've thought about having a mapping table like ArticlesRead which would simply have the address of each Reader & the ID of each Article, but how do I go about retrieving the Articles the Reader has purchased.
I think I'm getting a little hung up on how traditional arrays work..
I'm sure this is simple so any advice would be appreciated,
struct Article {
uint index;
string content;
uint price;
}
struct Reader {
address _address;
}
My code is pretty rubbish for now so I don't think it will help posting it
Thanks