RE: relations
Posted in 2000
See below...
-----Original Message-----
From: Obnoxio The Clown
To: martin@math.unl.edu.ar; informix-list@iiug.org
Sent: 6/28/00 4:56 AM
Subject: Re: relations
From: "Martin A. Marques" <martin@math.unl.edu.ar>
>
>On Wed, 28 Jun 2000, Obnoxio The Clown wrote:
> > From: "Martin A. Marques" <martin@math.unl.edu.ar>
> > >
> > >I'm about to insert data into a database which has some relations
>between
> > >three tables.
> > >
> > >base1.col2 -> base2.col1 (integers)
> > >base1.col3 -> base3.col1 (integers)
> > >
> > >Now, my question is: when I insert data into the database, how do I
> > >maintane
> > >the relation between the inserts of table base1, base2 and base3?
> > >
> > >More clearer: base1 is the mail table of articles, and in base2 I
put
>re
> > >resumes, and in base3 the whole article. When I'm inserting a new
>article,
> > >how do I keep the relation?
> >
> > Assuming I read your requirement correctly,
>http://www.informix.com/answers,
> > you have base1 as master of base2 and base3, in which case
> > http://www.informix.com/answers, you should insert first into base1
> > http://www.informix.com/answers, then base2 and base3.
>
>This only answers to one of my doubts. Do I have to do the relational
>insertion at programing level?
>
>Example:
>
>INSERT INTO base1 VALUES (a,b,c,d,e)
>INSERT INTO base2 VALUES (A,B,C)
>INSERT INTO base3 VALUES (x,y)>
>Now, I need b=A and c=x. I have to do this at a programing level?
Depends. Have you got the mind-reading datablade? If you have, then I'm
sure
the server will work out your data values for you.
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
=========================================================================
You can also establish referential integrity constraints between the
tables. In any case the "INSERT" commands should be issued within
a transaction:
BEGIN WORK;
INSERT INTO base1 VALUES (a,b,c,d,e);
INSERT INTO base2 VALUES (A,B,C);
INSERT INTO base3 VALUES (x,y); COMMIT WORK;
That will avoid partial updates.