Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with Paradox 9 table schema

11 views
Skip to first unread message

dwightarmy...@hotmail.com

unread,
Aug 17, 2008, 10:07:22 PM8/17/08
to
I'm a total newbie and I need some help creating my database tables. I
work with Paradox 9 through Borland C++ Builder 2006. I want to have
two database tables, one called Transactions and another called
TransactionDetails. Transactions has primary key TransactionID, which
is an ftString. TransactionDetails has a primary key (TransactionID,
TransactionAccountType) and both are strings.

Now, I want to make TransactionDetails be a child of Transactions so
that:

1. I cannot add a record to TransactionDetails (the child table)
without first adding it to Transactions (the parent table).
2. When I update a record in the Transactions table, the corresponding
record in TransactionDetails (i.e. the records with the same
TransactionID number) will also be updated. For example, if I go into
Transactions and change a record's TransactionID number from 1111 to
2222, it will automatically search in TransactionDetails for all
records that have a TransactionID number of 1111 and change those to
2222 automatically.

How do I form these two tables?

As it is now, I have C++ code that creates the two tables:

////////// CODE BEGINS HERE //////////

// create parent table
TTable* taTransactions = new TTable(this);
taTransactions->DatabaseName = "C:\\temp";
taTransactions->TableType = ttParadox;
taTransactions->TableName = "Transactions.db";
taTransactions->FieldDefs->Clear();
taTransactions->FieldDefs->Add("TransactionID", ftString, 10, true);
taTransactions->FieldDefs->Add("TransactionDate", ftDateTime, 0,
true);
taTransactions->FieldDefs->Add("TotalAmount", ftCurrency, 0, true);
taTransactions->IndexDefs->Clear();
taTransactions->IndexDefs->Add("", "TransactionID",
TIndexOptions()<<ixPrimary);

// create child table
TTable* taTransactionDetails = new TTable(this);
taTransactionDetails->DatabaseName = "C:\\temp";
taTransactionDetails->TableType = ttParadox;
taTransactionDetails->TableName = "TransactionDetails.db";
taTransactionDetails->FieldDefs->Clear();
taTransactionDetails->FieldDefs->Add("TransactionID", ftString, 10,
true);
taTransactionDetails->FieldDefs->Add("TransactionAccountType",
ftString, 5, true);
taTransactionDetails->FieldDefs->Add("TransactionType", ftString, 5,
true);
taTransactionDetails->FieldDefs->Add("AmountReceived", ftCurrency, 0,
true);
taTransactionDetails->FieldDefs->Add("AmountDisbursed", ftCurrency, 0,
true);
taTransactionDetails->FieldDefs->Add("AccountNumber", ftString, 8,
true);
taTransactionDetails->FieldDefs->Add("PersonID", ftString, 10, true);
taTransactionDetails->FieldDefs->Add("Percent", ftFloat, 0, true);
taTransactionDetails->IndexDefs->Clear();
taTransactionDetails->IndexDefs->Add("",
"TransactionID;TransactionAccountType", TIndexOptions()<<ixPrimary);

taTransactions->CreateTable();
taTransactionDetails->CreateTable();

// delete pointers
delete taTransactions; taTransactions = 0;
delete taTransactionDetails; taTransactionDetails = 0;

////////// CODE ENDS HERE //////////

Problem is I don't quite have it yet. As far as I can tell, there's no
"link" between Transactions and TransactionDetails. I asked this
question on the Paradox newsgroup, and they suggested I post it over
here. Can anybody help me?

0 new messages