Question about creation of records on many tables

[prev] [thread] [next] [Date index for 2004/09/22]

From: Andreas Fromm
Subject: Question about creation of records on many tables
Date: 10:05 on 22 Sep 2004
Hi,

Please consider the following Database

CREATE TABLE Users (
    id		serial PRIMARY KEY,
    name	text,
    address	int(4) references Addresses
);


CREATE TABLE Adresses (
    id		serial PRIMARY KEY,
    street	text,
    number	text,
);

Is it possible to set the CDBI-classes in such a way the if I pass a
hash containing the data for a new user with adress e.g.

$user = { name => 'Paul',
	  street => 'Homelane',
	  number => '56'
	};

to the create method of Users like in
   MyClass::Users->( $user );

I get the correct behavior that the adress-record is created first and
the id is used in the user-record, all by itself, or do I have to take
care to create the address-record first?

Thanks in advance.

Andreas Fromm


Question about creation of records on many tables
Andreas Fromm 10:05 on 22 Sep 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52