我想要做的插入到多个表,即Customer, Account, AccountTransactions
编辑
-
Entity - Customer
一对一 -
Customer - Account
被映射为一对一 -
Account - AccountTransactions
被映射为一对多
Entity(EntityId, EntityType)
ENTITYID主键自动递增
Customer(CustomerId, FName, LName)
客户ID = ENTITYID主键
Account(AccountId, AccountNo, CustomerId)
ACCOUNTID PK,客户ID FK
AccountTransactions(TransactionId, PaymentDate, CurrentBalance, AccountId)
TRANSACTIONID PK,FK ACCOUNTID
我的XML是:
<CustomerList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<Customer>
<CustomerId/>
<CustomerName>Abhishek</CustomerName>
<AccountId/>
<AccountNumber>eba5d378-b</AccountNumber>
<Transactions>
<Transaction>
<TransactionId/>
<PaymentDate>2/2/2012</PaymentDate>
<Amount>500</Amount>
</Transaction>
<Transaction>
<TransactionId/>
<PaymentDate>2/2/2012</PaymentDate>
<Amount>500</Amount>
</Transaction>
</Transactions>
</Customer>
<Customer>
<CustomerId/>
<CustomerName>Yash</CustomerName>
<AccountId/>
<AccountNumber>A101202</AccountNumber>
<Transactions>
<Transaction>
<TransactionId/>
<PaymentDate>2/2/2012</PaymentDate>
<Amount>500</Amount>
</Transaction>
<Transaction>
<TransactionId/>
<PaymentDate>2/2/2012</PaymentDate>
<Amount>500</Amount>
</Transaction>
</Transactions>
</Customer>
</CustomerList>
我要插入到Customer, Account, Transaction
表中的XML和在插入到客户每个客户其ID应该被保存回XML并在使用Account
表的外键
我可以看到唯一的办法就是使用嵌套游标或嵌套while循环。 是否有任何更好的方法存在?