Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-29 Thread Jonathan Bartlett
> Not *one* table. I never advocated that. It is perfectly normal to split > your data into different tables *vertically* (i.e. things that do not > have any intersection between their data, should go into different > tables), but it very rarely (if at all) makes any sense to split it > *horizontal

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-29 Thread Jonathan Bartlett
> Your programmers must be really smart :-) > Are you saying that you have never seen a person writing a piece of sql > like: > insert into mytable (id, data) select max(id) + 1 from mytable, 'mydata' > ??? > > If so, you must be really lucky :-) > I would never hire such a person. > Exactly. But

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-29 Thread Dmitry Tkach
Jonathan Bartlett wrote: NOTE - after writing all this, I did think of a possible solution, but I'm not sure if PG can handle it. If I made a table called "object" with one column, the object_id, and then had EVERY table inherit from this table. Then, I could have my constraints set up against th

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-29 Thread Jonathan Bartlett
NOTE - after writing all this, I did think of a possible solution, but I'm not sure if PG can handle it. If I made a table called "object" with one column, the object_id, and then had EVERY table inherit from this table. Then, I could have my constraints set up against this master table. (I'm not

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-29 Thread Dmitry Tkach
Jonathan Bartlett wrote: In the few instances where I go the other way, it's limited to 2 or 3 tables, and I do separate joins combined with a UNION. If you can combine your queries with a union, your table layouts must be very similar if not identical. Why not put everything into the same tab

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-29 Thread Jonathan Bartlett
> So, how can you possibly tell when looking at your note which entry it > applies to? That's easy - these are always referred from the table, never to the table. In the few instances where I go the other way, it's limited to 2 or 3 tables, and I do separate joins combined with a UNION. > When y

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-29 Thread Dima Tkach
Do you know of a better way to handle multitable references? Sure. SET CONSTRAINTS DEFERRED; BEGIN; insert this insert that END; That only handles single table references. For example, I have a database with a "notes" table. This table is used to store annotations on ANY record

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-28 Thread Jonathan Bartlett
Why not just drop the "references" clause? I mean, the point of having transactions is to guarantee integrity within a transaction, if you're not going to have that, why even bother with the clause? Most of my databases don't even user "references", just because I like the flexibility, and I have

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-28 Thread Dmitry Tkach
Jonathan Bartlett wrote: Why not just drop the "references" clause? I mean, the point of having transactions is to guarantee integrity within a transaction, if you're not going to have that, why even bother with the clause? Quite the opposite - the point is to guaratee the integrity *outside* th

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-28 Thread Rajesh Kumar Mallah
Stephan Szabo wrote: On Mon, 28 Jul 2003, kay-uwe.genz wrote: i've a little problem with two tables and FOREIGN KEYs. I've read about this long time ago, but didn't remember me where. Well, I hope you can help me. I've create two TABLEs "counties" and "cities". "Countries" have a

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-28 Thread Stephan Szabo
On Mon, 28 Jul 2003, kay-uwe.genz wrote: > i've a little problem with two tables and FOREIGN KEYs. I've read about > this long time ago, but didn't remember me where. Well, I hope you can > help me. > > I've create two TABLEs "counties" and "cities". "Countries" have a row > "capital" is REFERENCE

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-28 Thread Rajesh Kumar Mallah
kay-uwe.genz wrote: Hi @ all, i've a little problem with two tables and FOREIGN KEYs. I've read about this long time ago, but didn't remember me where. Well, I hope you can help me. I've create two TABLEs "counties" and "cities". "Countries" have a row "capital" is REFERENCEd "cities". "citie

Re: [GENERAL] CREATE TABLE with REFERENCE

2003-07-28 Thread Dmitry Tkach
kay-uwe.genz wrote: Hi @ all, i've a little problem with two tables and FOREIGN KEYs. I've read about this long time ago, but didn't remember me where. Well, I hope you can help me. I've create two TABLEs "counties" and "cities". "Countries" have a row "capital" is REFERENCEd "cities". "citie

[GENERAL] CREATE TABLE with REFERENCE

2003-07-28 Thread kay-uwe . genz
Hi @ all, i've a little problem with two tables and FOREIGN KEYs. I've read about this long time ago, but didn't remember me where. Well, I hope you can help me. I've create two TABLEs "counties" and "cities". "Countries" have a row "capital" is REFERENCEd "cities". "cities" have a row countr