Hi Guys, I'm thinking about the best way to store warranties about
products and I thought to create:
1 12 Months
2 24 Months
3 6 Months
product_id name warranty start warrantytype_id extendedwarranty 1 Samsung S2 01/01/2020 1 3 2 Samsung S4 01/02/2020 1 3
2 Samsung S3 30/12/2019 2 3
Extendedwarranty is linked to warrantytype_id, now I should understand
if it could be a good idea to add a field in products table named "expiredwarrantyday" to set if a product is out of warranty.
Why I thought to create a specific field about expiredwarrantyday?
Because I think I could add a code to calculate every day if a product
is out of warranty (expiredwarrantyday > today) and I could do a
"simple" query to this column to understand in a fast way how many
products are out of warranty!
It could be a good idea also to set a count down about warranty (for
example 10 days, one month, etc.) before the expired day but now I'd
like to know what do you think about it!
Do you think I could create another field named expiredwarranty (yes/no,
0/1) to be more fast to calculate what products are out of warranty? I
could run a script to calculate it every day...
If you only looking at the length, then just have a warranty length, not really need of a separate table for that.
Depends on how often you need that values, you can always use TIMESTAMPADD(MONTH, warranty_length, warranty_start)
, but of course if you need to make more advanced queries and need it indexed, then maybe better to store the value from start.
That you show with timestampadd + datediff, no need to make unneeded
A bit showing if a product still has warranty can be good, then you can exclude those already passed when you are looking for how many days it's
left until the warranty expires.
|Location:||Huddersfield, West Yorkshire, UK|
|Nodes:||8 (1 / 7)|