Hello All !!!

I've 2 tables in a Shopping Cart Servlet 
TransactionTable is having a one to many relation with OrderTable

create table TransactionTable (
TransId Integer Not Null Auto_Increment Primary Key,
OrderDate TimeStamp, Not Null ,
GrandTotal  Double Not Null ,
FullName VarChar(40)  Not Null  ,
Address   VarChar(100)  Not Null  ,
Pincode VarChar(10)  Not Null  ,
Phone VarChar(20)  Not Null  ,
Email VarChar(40)  Not Null  ,
city VarChar(20)  Not Null  ,
State VarChar(20)  Not Null  ,
Country VarChar(25)  Not Null ,
Comments VarChar(240)  
) ;

create table OrderTable (
OrderId  Integer Not Null Auto_Increment Primary Key,
TransId  Integer Not Null,
TotalPrice Double Not Null ,
Code VarChar(20)  Not Null ,
Quantity Integer Not Null
) ;

My problem is how to enforce integrity between the updates ? That is there will be 1 
or more enteries in the "OrderTable" againest every update in the "TransactionTable " 
table.
The  transId in Ordertable will be the same as the TransactionTable.
So i'll have to read the transID by the function " Last_Insert_ID () ";
But in the Event the database gets reset/ etc... etc... just after the Insert in the 
Transaction table it will leave the corresponding enteries orphaned in the OrdeTable . 
In that case what precautions should i take to avoid such scenarios?????

How should i impose a lock on the  tables ?? 

THe manual says 
To avoid using ROLLBACK, you can use the following strategy: 

  1.. Use LOCK TABLES ... to lock all the tables you want to access. 
  2.. Test conditions. 
  3.. Update if everything is okay. 
  4.. Use UNLOCK TABLES to release your locks. 
I didn't quite understasnd the meaning of Test Conditions

Any help will be deeply appreciated 
Best Regards
Sajan

 

Reply via email to