Re: [SQL] Delete with join -- deleting related table entries?

2006-02-08 Thread BigSmoke
I'm not sure if this is true for you as I can't see your complete table
definitions, but I'd usually do this by using

  issue_id INTEGER REFERENCES issue ON DELETE CASCADE

in my column definition.

See [1] for more information.

[1]http://www.postgresql.org/docs/current/interactive/ddl-constraints.html#DDL-CONSTRAINTS-FK


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [SQL] (NONE)

2006-02-08 Thread BigSmoke
Your question is not clear at all.


---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [SQL] regarding debugging?

2006-02-08 Thread BigSmoke
Checking how your PgSQL statements are executed, can be done using
EXPLAIN [1].

EXPLAIN ANALYZE will also execute (but not dry-run!) your statement.

I work with a seperate development and production database. Once the
changes to the schema in the development DB are done, I commit them to
the production DB using ActiveRecord migrations. You could do the same
with an advanced schema diff tool such as pgdiff [2] or zongle [3].

  - Rowan

[1] http://www.postgresql.org/docs/current/interactive/sql-explain.html
[2] http://pgdiff.sourceforge.net/
[3] http://zongle.sourceforge.net/


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [SQL] Non Matching Records in Two Tables

2006-02-09 Thread BigSmoke
You can use an EXCEPT clause.


---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [SQL] unique constraint instead of primary key? what disadvantage(ODBC usage)?

2006-02-09 Thread BigSmoke
If my tables have one or more UNIQUE constraints/indices, I still add a
"id SERIAL PRIMARY KEY" field to most of my tables. This makes
referencing easier and faster. It also improves consistency, which is
never a bad thing in my opinion.

As far as I know, though, PRIMARY KEY does the same thing as UNIQUE NOT
NULL in PostgreSQL.

The reason that PRIMARY KEY can't be NULL and _has to be_ UNIQUE is
that it is the primary means of identifying a given record in a table.
If you don't have PRIMARY KEY that is UNIQUE and NOT NULL, how are you
going to identify (or reference) individual records? PostgreSQL won't
allow you to reference more than one row for what I came to believe are
very good reasons.

  - Rowan


---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [SQL] unique constraint instead of primary key? what

2006-02-09 Thread BigSmoke
I mean that you can't easily base a foreign key constraint on a field
that is not NOT NULL UNIQUE.

  - Rowan


---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly