On 3/31/17 6:08 AM, 邱朗 wrote:
Say my mobile app has a customer table, a product table, and an order table to
record who buys what, the order table basically has 2 foreign keys, customer_id
& product_id.
Now I got the order information first, within in it I can't find the customer information
in my local sqlite table. As it turns out this is a new customer, whose information will
come later from another thread/queue. To make things even worse the customer id I got
from the order information is not the same one I used locally. My local customer id is
INTEGER PRIMARY KEY (I do record that "true customer id" as another column and
set index on it)
So how I do record this order information? I can come up with some clumsy solution, e.g. if I
can't find contact info, I insert a record for it first. Later after I get the real
information for this customer, I update customer & order table. But I was wondering is
there any "standard" way for the situation like this?
BTW, I did ask the same question at stackoverflow, but because I use sqlite
(while all the data come from web storing in MySQL) I was wondering if sqlite
has any specific solution for it.
Thanks,
Qiulang
This sounds like a problem in definition. Normally one would not 'book'
the order into the main database until it is complete and actually
placed, and at that point you should have all the data (you don't want
order delivery to start shipping the item(s) until the order is
confirmed and payed for) . While the order is being built, you normally
keep track of the data in a separate place, a 'shopping cart', and for
those things, you will be keying to shopping cart id (a session or
cookie id).
--
Richard Damon
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users