This is hard to explain but I'll try my best.
There is a sales table, that has a row for every article that a customer buy (simplified). so, for example, if a customer go to the store and buy 3 things, and then another customer buy 2 things, the sales table would looks like this:
ID | CUSTOMER_ID | ARTICLE_ID
1 21 42
2 21 32
3 21 34
4 22 42
5 22 33
The problem is that I need to add two new columns.
TRX_ID (transaction_id): it's when a customer visit the store, buy articles and leave.
TRX_COR (transaction_correlative): it's the position of the article by a transaction.
The result should show this:
ID | CUSTOMER_ID | ARTICLE_ID | TRX_ID | TRX_COR
1 21 42 1 1
2 21 32 1 2
3 21 34 1 3
4 22 42 2 1
5 22 33 2 2
With this information I might know how many transaction really are(2 in this case), and which is the first item to be sold, or passed through the paydesk (42 in this case), among other things.
Considerations:
I also stored the day (but not the exact time of the transaction)
There are a lot of customer by day
One customer can return during the day and that is a totally new transaction.
There is no way that two customers to buy at the same time.