CC me please.
How do I set up a one to many relationship in Postgres, (any DB for that
matter.)
I.E., if a delete or update of a child table causes a row in the parent
table to no longer refer to any rows in the child table, to either cause
Postgres to error out or delete the parent? I can see it does it for
when a parent is upudated or deleted.
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match 6 4808
So, you're looking for something like "referenced by" instead of the
SQL-standard "references"?
Seems like you could always whip up a stored procedure....
On May 16, 2004, at 9:27 AM, Dennis Gearon wrote: CC me please.
How do I set up a one to many relationship in Postgres, (any DB for that matter.)
I.E., if a delete or update of a child table causes a row in the parent table to no longer refer to any rows in the child table, to either cause Postgres to error out or delete the parent? I can see it does it for when a parent is upudated or deleted.
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Peter Eisentraut wrote: Dennis Gearon wrote:
How do I set up a one to many relationship in Postgres, (any DB for that matter.)
Read about foreign keys:
http://www.postgresql.org/docs/7.4/s...CONSTRAINTS-FK
That only takes care of if the PARENT is deleted/updated, if I read it
right. I'm trying to take care of the case where the CHILD is deleted or
updated, i.e. preserving 1-Many part of a rlationship.
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)
Dennis Gearon wrote: How do I set up a one to many relationship in Postgres, (any DB for that matter.)
Read about foreign keys: http://www.postgresql.org/docs/7.4/s...CONSTRAINTS-FK
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
On Sun, 16 May 2004, Dennis Gearon wrote: CC me please.
How do I set up a one to many relationship in Postgres, (any DB for that matter.)
I.E., if a delete or update of a child table causes a row in the parent table to no longer refer to any rows in the child table, to either cause Postgres to error out or delete the parent? I can see it does it for when a parent is upudated or deleted.
I don't think there's any built in direct way to do this right now, but
you could probably build triggers that would do it for you (the current
foreign key triggers might give a starting point. You'd probably also
want to use CREATE CONSTRAINT TRIGGER to be able to defer the trigger
(similarly to how the foreign key deferred works).
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
Stephan Szabo wrote: On Sun, 16 May 2004, Dennis Gearon wrote: CC me please.
How do I set up a one to many relationship in Postgres, (any DB for that matter.)
I.E., if a delete or update of a child table causes a row in the parent table to no longer refer to any rows in the child table, to either cause Postgres to error out or delete the parent? I can see it does it for when a parent is upudated or deleted.
I don't think there's any built in direct way to do this right now, but you could probably build triggers that would do it for you (the current foreign key triggers might give a starting point. You'd probably also want to use CREATE CONSTRAINT TRIGGER to be able to defer the trigger (similarly to how the foreign key deferred works).
I didn't know you could set up triggers to be deferred! AWESOME! That
makes for some additional flexibility that I could use.
Thank you very much Stephen. I was beginnning to consider TRIGGERS as
the solution; Now I know that they will work.
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org) Stephan Szabo wrote:
On Sun, 16 May 2004, Dennis Gearon wrote: CC me please.
How do I set up a one to many relationship in Postgres, (any DB for that matter.)
I.E., if a delete or update of a child table causes a row in the parent table to no longer refer to any rows in the child table, to either cause Postgres to error out or delete the parent? I can see it does it for when a parent is upudated or deleted.
I don't think there's any built in direct way to do this right now, but you could probably build triggers that would do it for you (the current foreign key triggers might give a starting point. You'd probably also want to use CREATE CONSTRAINT TRIGGER to be able to defer the trigger (similarly to how the foreign key deferred works). I didn't know you could set up triggers to be deferred! AWESOME! That makes for some additional flexibility that I could use.
Thank you very much Stephen. I was beginnning to consider TRIGGERS as the solution; Now I know that they will work.
Well, I should note that AFAIK CREATE CONSTRAINT TRIGGER is considered an
"internal" feature. It's unlikely to go away until it's considered okay
to break compatibility with 7.0/7.1 dumps however (and would be more
likely to be replaced with a more general feature anyway).
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Greg |
last post by:
Hello,
I've to manage many 'table' (having same scheme) on the same server.
And I ask myself what could be the best to do (and if you know, why) :
Creating as many database (the name would...
|
by: Mikey |
last post by:
Hi all. In the process of trying to figure this thing out, I've been
doing the old "stand around in the store and read as much as possible
before you look like a derelict" thing. This time, with...
|
by: Keith |
last post by:
I am having a problem creating a many-to-many-to-many type relationship. It
works fine, but when I create a view to query it and test it, it does not
generate the results I expected.
Below...
|
by: oNLINE bUDDY |
last post by:
How can you reverse a many-to-many XML structure between 2 tags?
Lets say we have a books/author XML file.
A book can have many authors.
<book1>
<Author1>
</Author1>
</book1>
|
by: Megan |
last post by:
hello everybody,
i know this is a very long post, but i wanted to provide as much
detail as possible.
quick overview- i want to create a couple of many to many
relationships and am wondering...
|
by: Johnny Meredith |
last post by:
Hi,
I'm building a database that, once a year, generates surveys that are emailed
to people in our organization. The recipients of the surveys are managers of
various departments. The emails...
|
by: Phil W |
last post by:
Hello,
I have set up my database in access using many to many relationships (it's
the good ol' books and authors one again). I've actually extended it to
include other people who contribute in...
|
by: the other john |
last post by:
The trouble currently with 3 tables. I'm excluding non-relevant
fields...
tbl_users
PK_user_ID
tbl_developers
PK_developer_ID
FK_developer_user_ID
FK_developer_project_ID
|
by: radiodave |
last post by:
I don't know how to ask this question but I'll try:
I'm making a database (Access 2003) for an Opera buff. I have tables related like:
each Opera has many Productions (Madame Butterfly has an...
|
by: RobertJohn |
last post by:
Hi all
I am using Access 2007 to start a small home library application, and so far it has two tables.
1. Books, with fields Book_ID (Primary Key) and Title, and
2. Authors, with fields...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |