Transaction history, how is it implemented?

Asked

Viewed 131 times

1

I need to make a history of the user’s last (s) purchase(s) (these links will be shown in a table).

Could you give me tips on how this history is usually saved? (don’t need to do it for me)

Normally a column is created and an array with numbers is saved inside it id'or all products are saved id's separated by commas? could you give me tips to implement this part?

will be shown to quantidade, id_produto, valor unitario do produro

  • it would be interesting to have some attempt of yours, for someone to help you. or it looks like do for me understand

  • Neither. Could give more details than you want to log

  • I did the update, I don’t know if it’s clear

  • Usually, if you save one id per line, it actually depends on the database you use

  • 1

    Improved, if possible add the table structures related to this process. In addition to the product what information will? quantity? delivery address? etc

1 answer

0

The basic idea of creating a history is to have a 'controlled denormalization' in your database. In other words, you need a new table where the fields are the descriptions of the 'objects' manipulated, some ids may be important as well.

Example:

A history table with the fields id, id_venda, endereco_entrega. The customer makes a purchase and during processing changes the delivery address of his registration, now imagine what would happen if the history table had the address id instead of his description? Store could ship the product to a wrong address since the customer can change this information when they want.

It is right to record your 'descriptive values' to record that exact purchase at that moment, something like taking a photo to compare it with another.

  • http://blog.vanderli.com.br/wp-content/uploads/2012/09/Foreign-keys.jpg would be something like this? make a Foreign key with another table? following the image example, the ID (Table Customers, probably this is auto incremental) will be referring to CUST_ID (Table Orders) (is not here?)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.