开发者

MySQL table design

开发者 https://www.devze.com 2022-12-13 23:09 出处:网络
I have a table with products. Each product has a title and a price. The products come in huge XML files, on a daily basis.

I have a table with products. Each product has a title and a price.

The products come in huge XML files, on a daily basis.

I store all of them in MySQL. But sometimes they have a wrong title. But i can't edit it, because they will be lost the next day (cronjob removes all products and inserts again).

What would be the best way to e开发者_开发百科dit them? Save them in a different table and SELECT both tables at once? Whereas the table that contains the edited rows has precedence over the cronjob table.

What would be the best way to handle it, since there are 300.000+ products. Products might be (manually) edited via a CMS system.

Thanks!


Is there some sort of ID that remains constant? (productID) for example?

Can you edit the cronjob?

If both of the above is true; i'd edit the job to only add new records into the table; preventing writing over your updated values.


If there is a unique identifier for each product that remains constant over updates, you could make a table containing the product ID and the corrected title. Correcting a title would involve inserting a row into this table as well as updating the main table.

As the last step of the cron job, you can then update your main table of products from this one.

UPDATE FROM tblProduct p, tblProductCorrections pc
SET p.strTitle = pc.strCorrectedTitle
WHERE p.intId = pc.intProductId
0

精彩评论

暂无评论...
验证码 换一张
取 消