Hello super experts, we have an application where users are asked to provide personal information like shipping address and mailing address.
There is a checkbox on the form that asks users if the shipping address they are providing is the same as mailing address. I did ask a small subset of this question last week.
If the user checks the box, it means shipping and mailing are the same.
On the DB side which is where my question comes from, there are two related tables.
There are several tables but these are the two significant ones.
One is called Addresses and the other is called Applications.
The Addresses table has several columns but but are relevant here, ID, Mailing and Shipping.
For a disclaimer, I did not build the app, neither did I design the database.
I have been with this company now for two years and the author of this app / db as I understand it, has been gone for over 5 years.
Both Shipping and Mailing fieldnames are of bit data type.
If Shipping and Mailing are both 1 (true), then both shipping and mailing are the same
If Shipping is 1 and mailing is 0 or mailing is 1 and shipping is 0, then shipping and mailing are different.
Then there is another field on Addresses table called ID, Surprisingly, this is not an identity seed.
To insert a value into this field, you have to select max(ID) + 1.
Then on the Applications table, the relevant fieldnames there are calling ShippingAddress and MailingAddress.
If shipping and mailing addresses are same, then both ShippingAddress and MailingAddress get the value of Shipping. If not, ShippingAdress gets the value of Shipping and MailingAdress gets the value of Mailing.
I have been able to successfully insert and query the correct records when shipping address and mailing address are same but struggling mightly to figure out how to assign values to both ShippingAddress and MailingAddress when the shipping and mailing addresses are different.
I am wondering if any of you super DB experts can help with how to handle this?