[RLUG] Is there a database guru out there?
Garrett P. Taylor
gtaylor at westerntitle.net
Mon Aug 15 08:08:34 PDT 2005
-----Original Message-----
From: Ben Johnson [mailto:ben at blarg.net]
Sent: Monday, August 15, 2005 12:18 AM
To: rlug at rlug.org
Subject: Re: [RLUG] Is there a database guru out there?
If you want to make sure all or nothing happens then use transactions.
In this situation, I'd say adding a new customer could be considerred an
operation that may be performed with or without a new order being
successfully linked, so there's no reason to bind the two insertions in
this way. just create a new customer, then somehow get the new customer
id and use that as part of the order data you insert later. If a
customer cannot exist without a linked order then do a "BEGIN"
transaction before you insert anything, then "COMMIT or "ROLLBACK"
depending on whether errors were encountered.
My suggestion here would be that you have a CustID field in the order
table that has a foreign_key constraint. That means any insertion will
fail if the CustomerID does not exist in the Customer Table.
- Ben
_______________________________________________
RLUG mailing list
RLUG at rlug.org
http://lists.rlug.org/mailman/listinfo/rlug
More information about the RLUG
mailing list