If you only looking at the length, then just have a warranty length, not really need of a separate table for that.
I'd like to have a separate table about warranty time because I'd like
to have a field for a standard warranty and another field for an
extended warranty.
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.
I read about TIMESTAMPADD but for example how could I manage something
like what I wrote above?
warranties
--------------------------
warranty_id month
1 12
2 6
productwarranties
--------------------
productwarranty_id 1
product_id_fk 20
warrantystartdate 01/01/2020
warranty_id 1
warrantystopdate 01/01/2021
warrantyextended 2
warrantystopdate2 01/06/2021
I wrote just what I'd like to have I know it's not right but I'd like to
store every warranties and maybe I could have "x" extended warranties
for a product not just two like what I wrote above!
It's important to see the story of every warranty because a customer
could have one or more than one extended warranty and it should be
possible to show it!
A factory would like to see if it gived to a customer more than one
warranty and not to show just the complete lengh...
I think I should have a warranty table linked in FK to the products and
I should remove warranty field from the product's table!
That you show with timestampadd + datediff, no need to make unneeded
table updates.
Timestampadd is very nice, I didn't know it and I didn't know also the
feature datediff but in my case it's not useful... :\
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.
Ok!
Thanks for every your replies! :)
^Bart
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)