Skip to content
Advertisement

Tag: database

How to avoid rails as_json creating flood of database requests

I have a model questions that has many tags through another model question_tags. I am trying to write an api endpoint that returns a list of questions and for each question a list of it’s related tag’s name and id. I’m currently using; But this runs a separate db request for every question in questions is there an alternative that

How I can update one to many relation in Postgres?

Here is my first table question. Questions have many options, so I referring every option row with question_id Now, How can I update both tables in one query? I building an API. The below-given output is for request. The request will response with question details and options for the question. I am able to update question but questions have many

Why store whole records in audit tables?

I worked in several companies and in each of them audit tables have been storing full snapshots of records for every change. To my understanding it’s enough to store only changed columns to recreate record in any given point of time. It will obviously reduce storage space. Moreover I suppose it would improve performance as we would need to write

Advertisement