Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Geraldo.

Asked: August 29, 2020 - 4:58 am UTC

Last updated: September 04, 2020 - 12:51 am UTC

Version: 18.6

Viewed 1000+ times

You Asked

Hello, Ask TOM Team.

I have a table A with 7 columns. I need to add two more columns (x, y) to this table or create a new one with a FK. These new columns could be "filled" with an insert or an update.

Business: We get XML invoices from customers. When XMLs arrives, they must be validated (schemas and business rules), meanwhile they are in *being processed state*. Then, when validation is finished (~1 sec), the application update the invoice state field in table A.

The insert method:
It would require create table B with three columns (PFK, x, y) because at the moment of insertion in table A I do not have the data to insert. So the app would insert in this child table.

The update method:
Add columns (x, y) to table A and then update them with an existing state update (mentioned above) in the application (I mean two more columns to the SET operator).

What is recommended for best practice: insert or update?

Thanks,

and Connor said...

On what you've provided, I would be going with the update method. This is a 1-to-1 relationship, and it sounds to me like all you'll end up doing with the insert method is having a view to join the two anyway.

A suitable pctfree or using the Hakan factor should ensure that the updates will not cause row chaining/migration issues.


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Review

Geraldo, September 03, 2020 - 4:03 am UTC

Thanks, Connor.

I will test that approach.
Connor McDonald
September 04, 2020 - 12:51 am UTC

glad we could help

More to Explore

Design

New to good database design? Check out Chris Saxon's full fundamentals class.