sql - How to find out if row being referenced changed? -
i've been thinking , looking solution problem don't know how search it. sorry if it's been answered.
context
i have app has persistence, , data provided rest api. 1 off calls supposed return new stuff, , comparing last time data retrieved time data changed. if changes newer retrieve, if not don't.
suppose we're working on schema:
company( id, address_id references address( id ), updated_at, ... ) equipment( id, address_id references address( id ), updated_at, ... ) address( id, updated_at, ... )
there trigger updates updated_at column on insert or update.
the api response when company , it's referenced address updated , equipment updated:
{ company:{ info, address:{ info } }, equipment:{ info } }
the problem
i'm retrieving company or equipment when changes occurred, , i'm retrieving address if company , equipment changed , address changed well. the problem when address changed, because api never return changes. can't return addresses changed because imply in lot of unnecessary data being downloaded.
i create query like:
select a.* company c, equipment e, address a.id = c.address_id or a.id = e.address_id , a.updated_at > "2000-01-01 00:00:00"
but doing response format lost, or necessary lot of server work relating each x returned it's respective element.
the solution thought creating trigger updates company's or equipment's updated_at column when address updated. however, doing retrieve old information tables references address, it's ok doing know if there better solution.
Comments
Post a Comment