[GENERAL] Foreign keys fails with partitioned table.

2016-12-21 Thread Edmundo Robles
I have a big,big table, this big table is referenced by another tables by foreign keys. I have a performance issues so i decide partition it by month -> ...,table_201610,table_201611,table_201612,... after i have been created the partition tables i try to insert data but foreign key

Re: [GENERAL] Foreign Keys as first class citizens at design time?

2015-08-14 Thread Stephen Feyrer
Hi, I agree with each of the points you've made. The idea here is meant as an extension of what is already available. So yes, this is intended to answer the questions of the designer's original model. The consideration being that you design your database and the underlying logic of your

Re: [GENERAL] Foreign Keys as first class citizens at design time?

2015-08-13 Thread Stephen Feyrer
On Fri, 14 Aug 2015 01:14:12 +0100, Adrian Klaver adrian.kla...@aklaver.com wrote: On 08/13/2015 05:03 PM, Stephen Feyrer wrote: Hi, This is probably not an original question merely one which I haven't been able to find an answer for. Basically, the question is why is there not an

Re: [GENERAL] Foreign Keys as first class citizens at design time?

2015-08-13 Thread Adrian Klaver
On 08/13/2015 05:03 PM, Stephen Feyrer wrote: Hi, This is probably not an original question merely one which I haven't been able to find an answer for. Basically, the question is why is there not an equivalent foreign key concept to match the primary key we all already know an love? How this

Re: [GENERAL] Foreign Keys as first class citizens at design time?

2015-08-13 Thread Adrian Klaver
On 08/13/2015 05:40 PM, Stephen Feyrer wrote: On Fri, 14 Aug 2015 01:14:12 +0100, Adrian Klaver adrian.kla...@aklaver.com wrote: On 08/13/2015 05:03 PM, Stephen Feyrer wrote: Hi, This is probably not an original question merely one which I haven't been able to find an answer for. Basically,

[GENERAL] Foreign Keys as first class citizens at design time?

2015-08-13 Thread Stephen Feyrer
Hi, This is probably not an original question merely one which I haven't been able to find an answer for. Basically, the question is why is there not an equivalent foreign key concept to match the primary key we all already know an love? How this would work, would be that the foreign key

Re: [GENERAL] Foreign Keys as first class citizens at design time?

2015-08-13 Thread David G. Johnston
On Thu, Aug 13, 2015 at 7:26 PM, Stephen Feyrer stephen.fey...@btinternet.com wrote: When we design databases, invariably, normally we design the queries at the same time. ​Well this may be true to an extent well implemented models have the ability to answer questions (queries) the original

Re: [GENERAL] Foreign Keys as first class citizens at design time?

2015-08-13 Thread Stephen Feyrer
On Fri, 14 Aug 2015 01:58:29 +0100, Adrian Klaver adrian.kla...@aklaver.com wrote: On 08/13/2015 05:40 PM, Stephen Feyrer wrote: On Fri, 14 Aug 2015 01:14:12 +0100, Adrian Klaver adrian.kla...@aklaver.com wrote: On 08/13/2015 05:03 PM, Stephen Feyrer wrote: Hi, This is probably not an

[GENERAL] foreign keys to foreign tables

2015-06-22 Thread Rick Otten
Hello pgsql-general, I'd like to set up a foreign key constraint to a foreign table from a local table. ie, I have a column in a local table that I'd like to ensure has a value in the foreign table. alter mytable add column some_column_id uuid references myforeigntable(some_column_id) ;

Re: [GENERAL] foreign keys to foreign tables

2015-06-22 Thread Rick Otten
Thanks Will! I had been considering setting up replication (using SymmetricDS - which we already use between other databases in our environment), but decided for this one check it was too much trouble. I may change my mind on that point again after all if I end up with a lot of dependencies like

Re: [GENERAL] foreign keys to foreign tables

2015-06-22 Thread Tom Lane
Rick Otten rottenwindf...@gmail.com writes: Hello pgsql-general, I'd like to set up a foreign key constraint to a foreign table from a local table. ie, I have a column in a local table that I'd like to ensure has a value in the foreign table. alter mytable add column some_column_id

Re: [GENERAL] foreign keys to foreign tables

2015-06-22 Thread William Dunn
Hello Rick, As I understand it you are correct. Oracle/DB2/Postgres and I think the SQL Standards to not implement constraints against tables on foreign servers. Although it would be possible to develop the DBMS to handle such constraints in a heterogeneous distributed environment it would be

Re: [GENERAL] foreign keys to foreign tables

2015-06-22 Thread Rick Otten
Obviously the server will be able to delete those rows because it will be completely unaware of this dependency. So it is the implied reverse constraint (of sorts) that can't be enforced which makes an FK based definition impossible. For my particular use case, this shouldn't be a problem. The

[GENERAL] Foreign keys

2013-12-18 Thread Dean Gibson (DB Administrator)
I have general question about FOREIGN KEYs: 1. Suppose I have table A with primary key X, and another table B with field Y. 2. When I 'ALTER TABLE B ADD FOREIGN KEY( Y ) REFERENCES A ON UPDATE CASCADE ON DELETE CASCADE', that clearly spends some time building a separate index.

Re: [GENERAL] Foreign keys

2013-12-18 Thread Rob Sargent
On 12/18/2013 11:02 AM, Dean Gibson (DB Administrator) wrote: I have general question about FOREIGN KEYs: 1. Suppose I have table A with primary key X, and another table B with field Y. 2. When I 'ALTER TABLE B ADD FOREIGN KEY( Y ) REFERENCES A ON UPDATE CASCADE ON DELETE

Re: [GENERAL] Foreign keys

2013-12-18 Thread Kevin Grittner
Dean Gibson (DB Administrator) postgre...@ultimeth.com wrote: I have general question about FOREIGN KEYs:     1. Suppose I have table A with primary key X, and another    table B with field Y.     2. When I 'ALTER TABLE B  ADD FOREIGN KEY( Y )  REFERENCES    A  ON UPDATE CASCADE  ON

Re: [GENERAL] Foreign keys

2013-12-18 Thread Dean Gibson (DB Administrator)
On 2013-12-18 10:41, Kevin Grittner wrote: Dean Gibson (DB Administrator) postgre...@ultimeth.com wrote: ... that clearly spends some time building a separate index. No it doesn't. If you are observing activity at that time, it is probably from validating that the constraint is initially

[GENERAL] foreign keys with constant part

2012-07-11 Thread Marc Mamin
Hello, I have to define a foreign relation to something like a unique partial index. I could do achieve this with triggers, but I already have too much of them, which make the model hard to understand. for now, I will just add a constant column which allows to define a standard foreign key.

Re: [GENERAL] Foreign keys question (performance)

2011-12-06 Thread Phoenix Kiula
On Sun, Dec 4, 2011 at 7:41 PM, Phoenix Kiula phoenix.ki...@gmail.com wrote: On Sun, Dec 4, 2011 at 7:14 PM, Alban Hertroys haram...@gmail.com wrote: On 4 Dec 2011, at 11:19, Phoenix Kiula wrote: INSERTs in the parent table don't need to check for any reference from the child table,

Re: [GENERAL] Foreign keys question (performance)

2011-12-06 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Phoenix Kiula Sent: Tuesday, December 06, 2011 11:46 AM To: Alban Hertroys Cc: PG-General Mailing List Subject: Re: [GENERAL] Foreign keys question (performance) On Sun

Re: [GENERAL] Foreign keys question (performance)

2011-12-06 Thread Adrian Klaver
On 12/06/2011 08:45 AM, Phoenix Kiula wrote: On Sun, Dec 4, 2011 at 7:41 PM, Phoenix Kiulaphoenix.ki...@gmail.com wrote: On Sun, Dec 4, 2011 at 7:14 PM, Alban Hertroysharam...@gmail.com wrote: On 4 Dec 2011, at 11:19, Phoenix Kiula wrote: I have a problem. Here's my table designs. The

[GENERAL] Foreign keys question (performance)

2011-12-04 Thread Phoenix Kiula
Hi. I have a foreign key as such: ALTER TABLE child_table ADD CONSTRAINT fk_child FOREIGN KEY (stringid) REFERENCES parent_table (stringid) MATCH FULL ON DELETE CASCADE ; Questions: 1. Is MATCH FULL adding any value here? If the foreign key is just on an id column, what purpose does it

Re: [GENERAL] Foreign keys question (performance)

2011-12-04 Thread Alban Hertroys
On 4 Dec 2011, at 11:19, Phoenix Kiula wrote: Hi. I have a foreign key as such: ALTER TABLE child_table ADD CONSTRAINT fk_child FOREIGN KEY (stringid) REFERENCES parent_table (stringid) MATCH FULL ON DELETE CASCADE ; Questions: 1. Is MATCH FULL adding any value here? If the

Re: [GENERAL] Foreign keys question (performance)

2011-12-04 Thread Phoenix Kiula
On Sun, Dec 4, 2011 at 7:14 PM, Alban Hertroys haram...@gmail.com wrote: On 4 Dec 2011, at 11:19, Phoenix Kiula wrote: INSERTs in the parent table don't need to check for any reference from the child table, since they're new; there can't be a reference. UPDATEs and DELETEs do though,

Re: [GENERAL] Foreign Keys and Deadlocks

2011-11-10 Thread Csaba Nagy
Hi David, On Wed, 2011-11-09 at 09:52 -0800, David Kerr wrote: So, aside from removing the PKs do i have any other options? Sure you have: order the inserts by primary key inside each transaction. Then you will not get deadlocks, but inserting the same key again will fail of course (but that's

Re: [GENERAL] Foreign Keys and Deadlocks

2011-11-10 Thread David Kerr
On Thu, Nov 10, 2011 at 09:09:06AM +0100, Csaba Nagy wrote: - Hi David, - - On Wed, 2011-11-09 at 09:52 -0800, David Kerr wrote: - So, aside from removing the PKs do i have any other options? - - Sure you have: order the inserts by primary key inside each transaction. - Then you will not get

Re: [GENERAL] Foreign Keys and Deadlocks

2011-11-09 Thread Alvaro Herrera
Excerpts from David Kerr's message of vie nov 04 13:01:29 -0300 2011: I did more digging and found some good discussions on the subject in general, but most of the examples out there contain explicit updates (which is why i was confused) but it looks like it's being addressed.

Re: [GENERAL] Foreign Keys and Deadlocks

2011-11-09 Thread David Kerr
On Wed, Nov 09, 2011 at 11:11:23AM -0300, Alvaro Herrera wrote: - - Excerpts from David Kerr's message of vie nov 04 13:01:29 -0300 2011: - - I did more digging and found some good discussions on the subject in general, but - most of the examples out there contain explicit updates (which is

Re: [GENERAL] Foreign Keys and Deadlocks

2011-11-09 Thread Alvaro Herrera
Excerpts from David Kerr's message of mié nov 09 14:52:01 -0300 2011: On Wed, Nov 09, 2011 at 11:11:23AM -0300, Alvaro Herrera wrote: - This case is not helped by the patch I'm working on. As far as I can - see, if you got rid of the PK in table a in your example script, things - should

Re: [GENERAL] Foreign Keys and Deadlocks

2011-11-05 Thread Csaba Nagy
Hi David, On Thu, 2011-11-03 at 15:30 -0700, David Kerr wrote: I suspect that it has to be a transaction, and that further up in the TX is an update to one of the reference tables in each TX. This is your cause - updating the referenced table in the same transaction. That will want an

Re: [GENERAL] Foreign Keys and Deadlocks

2011-11-04 Thread David Kerr
On Thu, Nov 03, 2011 at 03:30:20PM -0700, David Kerr wrote: - Howdy, - - We have a process that's deadlocking frequently. It's basically multiple threads inserting data into a single table. - - That table has FK constraints to 3 other tables. - - I understand how an FK check will cause a

[GENERAL] Foreign Keys and Deadlocks

2011-11-03 Thread David Kerr
Howdy, We have a process that's deadlocking frequently. It's basically multiple threads inserting data into a single table. That table has FK constraints to 3 other tables. I understand how an FK check will cause a sharelock to be acquired on the reference table and in some instances that

[GENERAL] foreign keys and inheritance problem

2010-08-12 Thread Edoardo Panfili
hi, I am in some trouble with my tables defined using inheritance, This is a semplified test case: --- create table sub1( name1 text) inherits(father); create table sub2( name2 text) inherits(father); create table other (description text, id integer); -- I know, the

Re: [GENERAL] foreign keys and inheritance problem

2010-08-12 Thread Edoardo Panfili
On 12/08/10 18.59, Edoardo Panfili wrote: hi, I am in some trouble with my tables defined using inheritance, This is a semplified test case: --- create table sub1( name1 text) inherits(father); create table sub2( name2 text) inherits(father); create table other (description

Re: [GENERAL] foreign keys and inheritance problem

2010-08-12 Thread Tom Lane
Edoardo Panfili edoa...@aspix.it writes: On 12/08/10 18.59, Edoardo Panfili wrote: I am in some trouble with my tables defined using inheritance, No, foreign keys do not play very nicely with inheritance. There is some explanation in the manual, in the Caveats subsection under Inheritance ---

Re: [GENERAL] foreign keys and inheritance problem

2010-08-12 Thread Edoardo Panfili
On 12/08/10 20.44, Tom Lane wrote: Edoardo Panfiliedoa...@aspix.it writes: On 12/08/10 18.59, Edoardo Panfili wrote: I am in some trouble with my tables defined using inheritance, No, foreign keys do not play very nicely with inheritance. There is some explanation in the manual, in the

Re: [GENERAL] Foreign keys and permissions oddity

2010-08-07 Thread Richard Huxton
On 07/08/10 01:13, Joshua Tolley wrote: Is there some justification for this behavior that I should know already? It seemed awfully strange when some folkds here stumbled on it: [snip] The key point seems to be that the owner of the referenced table has no permissions on the table, although

Re: [GENERAL] Foreign keys and permissions oddity

2010-08-07 Thread Joshua Tolley
On Sat, Aug 07, 2010 at 08:34:12AM +0100, Richard Huxton wrote: On 07/08/10 01:13, Joshua Tolley wrote: Is there some justification for this behavior that I should know already? It seemed awfully strange when some folkds here stumbled on it: [snip] The key point seems to be that the owner of

[GENERAL] Foreign keys and permissions oddity

2010-08-06 Thread Joshua Tolley
Is there some justification for this behavior that I should know already? It seemed awfully strange when some folkds here stumbled on it: $ create user a; $ create user b; $ commit; $ \c - a $ create table foo (id integer primary key); $ revoke all on foo from a; $ grant all on foo to b; $

Re: [GENERAL] Foreign keys causing conflicts leading toserialization failures

2008-04-03 Thread Albe Laurenz
Tom Lane wrote: This is what I am wondering. Whether it is done this way due to expecation/standard, or as an implementation side effect. In the latter case it is fixable. I don't see how this could break a standard. Actually, I think it does, because we went to great lengths to cause

Re: [GENERAL] Foreign keys causing conflicts leading to serialization failures

2008-04-02 Thread Albe Laurenz
Peter Schuller wrote: Using PostgreSQL 8.2, I have atable one of whose columns reference a column in othertable. I see serialization failures as a result of *inserts* to atable in the context of: 'SELECT 1 FROM ONLY othertable x WHERE otherid = $1 FOR SHARE OF x ' in 'INSERT INTO atable

Re: [GENERAL] Foreign keys causing conflicts leading to serialization failures

2008-04-02 Thread Peter Schuller
A SELECT ... FROM othertable ... FOR SHARE won't conflict with a concurrent update on atable. Do I guess right that there was also an UPDATE on the row in othertable? Yes, that was what I meant to convey. Sorry if I was not clear. The point was that an INSERT to atable conflicted with an

Re: [GENERAL] Foreign keys causing conflicts leading toserialization failures

2008-04-02 Thread Albe Laurenz
Peter Schuller wrote: [about a serialization error caused by a foreign key constraint] Transaction 2 now issues an INSERT on atable. This requires a RowShareLock on the index row of the index on othertable that is referenced by the foreign key constraint. But the corresponding index row has

Re: [GENERAL] Foreign keys causing conflicts leading toserialization failures

2008-04-02 Thread Tom Lane
Albe Laurenz [EMAIL PROTECTED] writes: Peter Schuller wrote: This is what I am wondering. Whether it is done this way due to expecation/standard, or as an implementation side effect. In the latter case it is fixable. I don't see how this could break a standard. Actually, I think it does,

[GENERAL] Foreign keys causing conflicts leading to serialization failures

2008-04-01 Thread Peter Schuller
Hello, Using PostgreSQL 8.2, I have atable one of whose columns reference a column in othertable. I see serialization failures as a result of *inserts* to atable in the context of: 'SELECT 1 FROM ONLY othertable x WHERE otherid = $1 FOR SHARE OF x ' in 'INSERT INTO atable (otherid, col2,

Re: [GENERAL] Foreign keys to inherited tables

2008-03-20 Thread Leon Mergen
On 3/20/08, Erik Jones [EMAIL PROTECTED] wrote: I think he's talking about foreign keys from a partitioned table, i.e. a parent and all of its child tables, to another table. That would, at first, sound simple, but scenarios like this make it tricky as something to be handled automatically

[GENERAL] Foreign keys to inherited tables

2008-03-19 Thread Leon Mergen
Hello, I was wondering, I'm reading that there is no support for foreign keys to inherited (child) tables -- are there any plans on supporting these in the (near) future, and/or are there any practical workarounds for this ? Regards, Leon Mergen -- Sent via pgsql-general mailing list

Re: [GENERAL] Foreign keys to inherited tables

2008-03-19 Thread brian
Leon Mergen wrote: Hello, I was wondering, I'm reading that there is no support for foreign keys to inherited (child) tables -- are there any plans on supporting these in the (near) future, and/or are there any practical workarounds for this ? This has worked well for me: CREATE TABLE

Re: [GENERAL] Foreign keys to inherited tables

2008-03-19 Thread Erik Jones
On Mar 19, 2008, at 10:42 PM, brian wrote: Leon Mergen wrote: Hello, I was wondering, I'm reading that there is no support for foreign keys to inherited (child) tables -- are there any plans on supporting these in the (near) future, and/or are there any practical workarounds for this ?

[GENERAL] Foreign keys and inheritance

2007-11-19 Thread Kynn Jones
I have two classes of objects, A and B, where B is just a special case of A. (I.e., to describe a B-type object I need to specify the same fields as for an A-type object, plus a whole bunch additional fields specific to B alone.) Furthermore, there's a third class T that is in a many-to-one

Re: [GENERAL] Foreign keys and inheritance

2007-11-19 Thread Jeff Davis
On Mon, 2007-11-19 at 14:36 -0500, Kynn Jones wrote: I have two classes of objects, A and B, where B is just a special case of A. (I.e., to describe a B-type object I need to specify the same fields as for an A-type object, plus a whole bunch additional fields specific to B alone.)

Re: [GENERAL] Foreign keys and inheritance

2007-11-19 Thread brian
Kynn Jones wrote: I have two classes of objects, A and B, where B is just a special case of A. (I.e., to describe a B-type object I need to specify the same fields as for an A-type object, plus a whole bunch additional fields specific to B alone.) Furthermore, there's a third class T that is

Re: [GENERAL] Foreign keys and inheritance

2007-11-19 Thread Alvaro Herrera
Kynn Jones escribió: I have two classes of objects, A and B, where B is just a special case of A. (I.e., to describe a B-type object I need to specify the same fields as for an A-type object, plus a whole bunch additional fields specific to B alone.) Furthermore, there's a third class T that

Re: [GENERAL] Foreign keys and inheritance

2007-11-19 Thread Jeff Davis
On Mon, 2007-11-19 at 17:19 -0300, Alvaro Herrera wrote: Kynn Jones escribió: I have two classes of objects, A and B, where B is just a special case of A. (I.e., to describe a B-type object I need to specify the same fields as for an A-type object, plus a whole bunch additional fields

[GENERAL] foreign keys and memory consumption

2007-10-09 Thread Jan Poslusny
Hi all, pg 8.2.4 on Fedora Core 6 x86-64, mostly default postgres.conf just shared memory buffers increased to 256M. 1GB RAM. I attempt to insert ~200k rows into table in one transaction from psql console, calling stored function of plperlu language, which inserts row by row via

Re: [GENERAL] foreign keys and memory consumption

2007-10-09 Thread Simon Riggs
On Tue, 2007-10-09 at 11:28 +0200, Jan Poslusny wrote: pg 8.2.4 on Fedora Core 6 x86-64, mostly default postgres.conf just shared memory buffers increased to 256M. 1GB RAM. I attempt to insert ~200k rows into table in one transaction from psql console, calling stored function of plperlu

[GENERAL] Foreign keys and indexes

2007-06-05 Thread Marc Compte
Dear list, This might be too basic for a question but I just couldn't find the answer so far. Does PostgreSQL create an implicit index also for foreign keys? or must I create it explicitly? Thank you, Marc Compte ---(end of broadcast)---

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Filip Rembiałkowski
2007/6/5, Marc Compte [EMAIL PROTECTED]: Dear list, This might be too basic for a question but I just couldn't find the answer so far. Does PostgreSQL create an implicit index also for foreign keys? or must I create it explicitly? FK is just a constraint, you wil have to create indexes

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Ragnar
On þri, 2007-06-05 at 11:49 +0200, Marc Compte wrote: Does PostgreSQL create an implicit index also for foreign keys? no or must I create it explicitly? if you want one, yes. not everyone wants an index on all their foreign keys, but they can be useful in some circumstances. gnari

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Michael Fuhr
On Tue, Jun 05, 2007 at 11:49:20AM +0200, Marc Compte wrote: Does PostgreSQL create an implicit index also for foreign keys? or must I create it explicitly? PostgreSQL doesn't create an index on the referencing column(s) of a foreign key constraint; if you want an index then you'll need to

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Richard Broersma Jr
Does PostgreSQL create an implicit index also for foreign keys? or must I create it explicitly? No, you foreign keys are not automatically indexed. They only way they would be is if the FK is part of a composite unique or primary key. So you will probably have to create your one indexes on

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread A. Kretschmer
am Tue, dem 05.06.2007, um 11:49:20 +0200 mailte Marc Compte folgendes: Dear list, This might be too basic for a question but I just couldn't find the answer so far. Does PostgreSQL create an implicit index also for foreign keys? No, only for primary keys to enforce the uniqueness.

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Gregory Stark
Marc Compte [EMAIL PROTECTED] writes: Does PostgreSQL create an implicit index also for foreign keys? or must I create it explicitly? It won't allow you to create a foreign key that points to a column without a unique index on it. postgres=# create table b (i integer references a(i)); ERROR:

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Marc Compte
Thanks to everyone for the prompt reply :) Good thing about answers is when they raise up new questiosn, so you can keep on learning all the time. This one answer, for instance, brings me another question. Does having a composite primary mean the system will create an individual index on

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Scott Marlowe
Marc Compte wrote: Thanks to everyone for the prompt reply :) Good thing about answers is when they raise up new questiosn, so you can keep on learning all the time. This one answer, for instance, brings me another question. Does having a composite primary mean the system will create an

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Oliver Elphick
On Tue, 2007-06-05 at 17:07 +0200, Marc Compte wrote: For instance, in the implementation of a N:M relationship, declaring the primary as (foreign1, foreign2) will create two indexes? or just one? Just one -- Oliver Elphick [EMAIL PROTECTED] Isle

[GENERAL] Foreign keys, table inheritance, and TRUNCATE

2007-01-30 Thread Florian Weimer
Here's something I've just noticed: CREATE TABLE foo (f INTEGER PRIMARY KEY); INSERT INTO foo VALUES (1); CREATE TABLE bar (b INTEGER REFERENCES foo); CREATE TABLE bar1 () INHERITS (bar); INSERT INTO bar1 VALUES (1); This is quite correct: TRUNCATE foo; ERROR: cannot truncate a table

Re: [GENERAL] Foreign keys, table inheritance, and TRUNCATE

2007-01-30 Thread Alvaro Herrera
Florian Weimer wrote: Here's something I've just noticed: CREATE TABLE foo (f INTEGER PRIMARY KEY); INSERT INTO foo VALUES (1); CREATE TABLE bar (b INTEGER REFERENCES foo); CREATE TABLE bar1 () INHERITS (bar); INSERT INTO bar1 VALUES (1); This is quite correct: No, it isn't; try

[GENERAL] Foreign keys, arrays, and uniqueness

2006-10-02 Thread Morgan Kita
Let me start by saying I understand that postgresql does not support the following: composite data types with individual components acting as foreign keys, arrays of composite data types, and arrays with elements acting as foreign keys. I will layout my example using them for clarity even though

[GENERAL] Foreign keys and slow insert

2005-06-08 Thread Dan Black
I read in documentation that primary key doesn't require additional indexes but I could find nothing about foreign keys. Do I need to create additional indexes when I create foreign keys? Example: create table master { master_id INT4, master_name VARCHAR(64), CONSTRAINT master_pkey PRIMARY KEY

Re: [GENERAL] Foreign keys and slow insert

2005-06-08 Thread Stephan Szabo
On Wed, 8 Jun 2005, Dan Black wrote: I read in documentation that primary key doesn't require additional indexes but I could find nothing about foreign keys. Do I need to create additional indexes when I create foreign keys? Example: create table master { master_id INT4, master_name

Re: [GENERAL] Foreign keys and slow insert

2005-06-08 Thread Richard Huxton
Dan Black wrote: I read in documentation that primary key doesn't require additional indexes but I could find nothing about foreign keys. Do I need to create additional indexes when I create foreign keys? Example: create table master create table slave Do I need to create index CREATE

Re: [GENERAL] Foreign keys and slow insert

2005-06-08 Thread Dan Black
I've observed that inserts into slave table became slower when I use foreign key than without one. Can it be related to foreign key? And I am interested how much performance of database with foreign keys can be different from performance of database without foreign keys? In other words, how much

Re: [GENERAL] Foreign keys and slow insert

2005-06-08 Thread Scott Marlowe
On Wed, 2005-06-08 at 12:39, Dan Black wrote: I've observed that inserts into slave table became slower when I use foreign key than without one. Can it be related to foreign key? And I am interested how much performance of database with foreign keys can be different from performance of

Re: [GENERAL] Foreign keys and slow insert

2005-06-08 Thread Dan Black
I think 21 interns will be enough :)2005/6/8, Scott Marlowe [EMAIL PROTECTED]: On Wed, 2005-06-08 at 12:39, Dan Black wrote: I've observed that inserts into slave table became slower when I use foreign key than without one. Can it be related to foreign key? And I am interested how muchperformance

[GENERAL] Foreign Keys Question

2005-04-13 Thread Matthias Loitsch
First of all, hi. I'm new to this mailing list. I searched this on the net, but I didn't get any usable answers... So here's my problem: I have 2 schemas. One is called SITE, one SITE_forum. What I wanted, is to separate the forum from the whole Site db, so I can put them on different

Re: [GENERAL] Foreign Keys Question

2005-04-13 Thread Bruno Wolff III
On Wed, Apr 13, 2005 at 13:54:05 +0200, Matthias Loitsch [EMAIL PROTECTED] wrote: So I thought I could make a foreign key on a different Schema (db), and use the same table And well, thats where I started to search if this is possible ... and, in fact my main question is: Is this a

Re: [GENERAL] Foreign Keys Question

2005-04-13 Thread Oleg Bartunov
Will inherits helps you ? create table SITE_forum.t1 () inherits (SITE.t); Oleg On Wed, 13 Apr 2005, Matthias Loitsch wrote: First of all, hi. I'm new to this mailing list. I searched this on the net, but I didn't get any usable answers... So here's my problem: I have 2 schemas. One is called

[GENERAL] Foreign keys on inherited attributes

2004-01-26 Thread Shawn Harrison
Greetings, I'm using pg 7.3.5 and playing with table inheritance, and I've run into the fact that foreign keys cannot be defined on inherited attributes. (As much is stated in the documentation, but it didn't sink in until I ran into the fact.) The documents say this will probably be fixed in a

Re: [GENERAL] Foreign keys and pg_user table

2003-12-13 Thread dj trombley
Well, it's not a table! It's a view: dbs=# \d pg_user View pg_catalog.pg_user Column| Type | Modifiers -+-+--- usename | name| usesysid| integer | usecreatedb | boolean | usesuper| boolean | usecatupd | boolean | passwd | text

Re: [GENERAL] Foreign keys

2003-06-28 Thread weigelt
On Thu, Jun 26, 2003 at 02:12:22PM +0100, Richard Huxton wrote: snip It looks like he has a centralised address table with customer_addresses linking customer to address. Likewise for supplier. His problem was he wanted to remove address details when nothing referred to them any more.

[GENERAL] Foreign keys

2003-06-26 Thread Matt Browne
Hello! I have a question regarding foreign keys and general garbage collection of data... If anyone could provide assistance, it'd be much appreciated! Basically, we have a fairly complex database, with many tables (customers, etc) that need to reference addresses that are contained in a generic

Re: [GENERAL] Foreign keys

2003-06-26 Thread Bruno Wolff III
On Thu, Jun 26, 2003 at 12:00:07 +0100, Matt Browne [EMAIL PROTECTED] wrote: Other tables also reference records in the address table, using a similar sort of scheme. I have foreign keys set up so that if, for example, a record in customer is deleted, the corresponding records in the

FW: [GENERAL] Foreign keys

2003-06-26 Thread Benjamin Jury
I have foreign keys set up so that if, for example, a record in customer is deleted, the corresponding records in the customer_addresses table are also removed. However, I can't find a way of ensuring records in the address table are deleted too, given that lots of different tables will

Re: [GENERAL] Foreign keys

2003-06-26 Thread Jan Wieck
Matt Browne wrote: Hello! I have a question regarding foreign keys and general garbage collection of data... If anyone could provide assistance, it'd be much appreciated! Basically, we have a fairly complex database, with many tables (customers, etc) that need to reference addresses that are

Re: [GENERAL] Foreign keys

2003-06-26 Thread Matt Browne
Hello again - This problem has now been resolved, using triggers. A big thank you to everyone who reponded! I'd buy you all a beer if... Er... This list was a bar. Cheers! -- Matt Browne [EMAIL PROTECTED] ---(end of broadcast)--- TIP 4: Don't

Re: [GENERAL] Foreign keys

2003-06-26 Thread Richard Huxton
On Thursday 26 Jun 2003 1:40 pm, Rich Shepard wrote: Matt Browne wrote: Basically, we have a fairly complex database, with many tables (customers, etc) that need to reference addresses that are contained in a generic address table. So: customer_addresses [table]

[GENERAL] Foreign keys

2001-08-27 Thread Neal Lindsay
If I create a columnA in a tableA that REFERENCES tableB(columnB) in another table, where column B is not null, does that imply a NOT NULL on my columnA? In other words, does it ensure that the value of A is in the set of values for B, or that the value of A is in the Bs unless A is null?

Re: [GENERAL] Foreign keys

2001-08-27 Thread Stephan Szabo
On Mon, 27 Aug 2001, Neal Lindsay wrote: If I create a columnA in a tableA that REFERENCES tableB(columnB) in another table, where column B is not null, does that imply a NOT NULL on my columnA? In other words, does it ensure that the value of A is in the set of values for B, or that the

Re: [GENERAL] Foreign Keys

2001-07-17 Thread Bruce Momjian
How can you get a listing of foreign keys to a table? We haven't figure out a good way yet. The pg_depend discussion on hackers may lead to a solution if we evern implement it. -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610)

Re: [GENERAL] Foreign keys?

2001-07-13 Thread Jason Earl
It was a little bit late when I wrote that, and so I probably should have been a little more specific. I don't know if you would notice a performance difference between the joined tables query and and the non-joined version for such simple tables. I might have to spend a bit of time today

Re: [GENERAL] Foreign Keys to Non-primary keys?

2001-06-21 Thread Stephan Szabo
On Thu, 21 Jun 2001 [EMAIL PROTECTED] wrote: Is it possible to have a foreign key to a non-primary key (also meaning non-unique and therefore non-indexed) column i a table? Generally no. It's not allowed by the spec, so as of 7.1, we prevent it. Admittedly, you could pull the rug out

Re: [GENERAL] foreign keys constraints, depending on each other

2001-06-12 Thread Mario Weilguni
Am Montag, 11. Juni 2001 10:25 schrieb Marc SCHAEFER: I would remove the father and mother references, and add a    is_married relation; as a table, with a UNIQUE(father_id), UNIQUE(mother_id) constraint (a person can be only married once). Is not true, at least not in some arabic

Re: [GENERAL] foreign keys constraints, depending on each other

2001-06-10 Thread Stephan Szabo
On Sun, 10 Jun 2001 [EMAIL PROTECTED] wrote: I was just creating this little database for demonstrating the use of foreign keys constraints. I was about the create 3 tables, namely mother, father and child. Mother has a foreign key pointing at father ( id ), and father has a

Re: [GENERAL] Foreign keys/unique values and views

2001-03-22 Thread Einar Karttunen
On Thu, 22 Mar 2001, Richard Huxton wrote: I have to admit I've never tried referencing a view with a foreign key. I don't know if it's possible and I have to admit the idea makes me uncomfortable. Can't give a good reason why, but I'd apply constraints at the table level. if one can

Re: [GENERAL] Foreign keys/unique values and views

2001-03-22 Thread Martijn van Oosterhout
On Thu, Mar 22, 2001 at 06:33:16PM -0500, Jan Wieck wrote: Einar Karttunen wrote: How do you put a UNIQUE constraint on the entire inheritance hierarchie? Easy. You make a unique index that covers an entire inheritance hierarchy. If lots of table inherit a field "id" from a single

Re: [GENERAL] Foreign keys

2001-02-19 Thread Stephan Szabo
You can reconstruct the information out of the triggers that are created in pg_trigger. It's not easy to parse however. There are three triggers created for each fk constraint, one on the fk table, two on the pk table. You can get the tables, columns constrained and match type from the

[GENERAL] Foreign Keys

2001-02-05 Thread No Name
I have PostgreSQL 6.5, and I can't get foreign keys to work! What seems to be the problem?

Re: [GENERAL] Foreign Keys

2001-02-05 Thread Adam Haberlach
On Thu, Feb 01, 2001 at 07:59:16PM -0500, No Name wrote: I have PostgreSQL 6.5, and I can't get foreign keys to work! What seems to be the problem? Your database is too purple. -- Adam Haberlach|A cat spends her life conflicted between a [EMAIL PROTECTED] |deep, passionate,

[GENERAL] Foreign keys, adding to table.

2000-10-27 Thread Ben Souther
Quick easy one: Could someone please tell me the syntax for adding a foreign key constraint to an existing row in an existing table. Thanks.

  1   2   >