pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
data integrity 2+ messages / 2 participants [nested] [flat]
* data integrity @ 2000-08-15 11:30 Sandis <sandisj@parks.lv> 0 siblings, 1 reply; 2+ messages in thread From: Sandis @ 2000-08-15 11:30 UTC (permalink / raw) To: pgsql-sql Hello pgsql-sql, sorry for my question that is obviously a kind of lame and not related directly to postges, but i never dealt with it before & need an idea what to do right now. there is a db with a few tables that have related (joined) fields. if record in a one table (auxiliary) gets deleted (along with it's primary key), reference to it in another table (main) points to nowhere. then doing a complex query with a join on that tables doesn't return such corrupted rows that contains references to deleted rows in other tables. what's the solution? should i check if this 'project', for example, have 'contacts' associated with it, and do not allow user to delete it, than show that 'contacts' list and ask if she wants delete all of them? or may be dont show a list, but just warn that there is $number 'contacts' related to this 'project', do you want to delete them all? how about joins in delete query? DELETE FROM projects, contacts WHERE projects.contact = contacts.id AND projects.id = '$id'; he, i wrote the answer myself. may be dont send it at all? can someone suggest some good online resource where such common sql topics discussed? thanks --:)-- Best regards, Sandis mailto:sandisj@parks.lv ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: data integrity @ 2000-08-15 13:04 Jesus Aneiros <aneiros@jagua.cfg.sld.cu> parent: Sandis <sandisj@parks.lv> 0 siblings, 0 replies; 2+ messages in thread From: Jesus Aneiros @ 2000-08-15 13:04 UTC (permalink / raw) To: Sandis <sandisj@parks.lv>; +Cc: pgsql-sql On Tue, 15 Aug 2000, Sandis wrote: > there is a db with a few tables that have related (joined) fields. if > record in a one table (auxiliary) gets deleted (along with it's I would say this is the primary table. > primary key), reference to it in another table (main) points to And this is the secondary tab,le which references the other. > what's the solution? should i check if this 'project', for example, The solution is called referential integrity. you should use the foreign key and references clause with cascade. > can someone suggest some good online resource where such common sql topics > discussed? I would like to know such a place. Jesus. ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-08-15 13:04 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2000-08-15 11:30 data integrity Sandis <sandisj@parks.lv> 2000-08-15 13:04 ` Jesus Aneiros <aneiros@jagua.cfg.sld.cu>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox