nattaponaie / nimble-challenge

0 stars 0 forks source link

Data structure improvements #12

Closed olivierobert closed 4 years ago

olivierobert commented 4 years ago

First, keyword_data is not really a great name for a table 😭 (prefer removing data from your vocabulary to name anything as it's too abstract) Second, in terms of data normalization, it would be better to split the keyword from the scraping results. Finally, in terms of authorization, keywords must belong to a user so that each user can only see its data.

So how about the following:

class Keyword
  belongs_to :user
  has_many :reports # Technically if a user uploads many times the same keyword, one does not need to create over and over again but just schedule a new scraping report to be created 
end

# Store all scarping results
class Report 
  belongs_to :keyword
end
nattaponaie commented 4 years ago

Oops, I thought the requirement was something like a admin portal that anyone could see keyword data. So, that why I've done like this.

However, I am happy to fix this issue 😃

olivierobert commented 4 years ago

Apologies if the requirements were not clear enough. Since users have to log in, all keywords should belong to that user :-)

Revisited in #18