I have CDs from over 10-15 years ago and they are still OK, but I keep them in a CD folder so they are not exposed to daylight or sunlight.
Years ago I did a test on DVDs to see how long the data would last when exposed to sunlight.
The answer was not very long - after just a few days on a window sill exposed to sunlight the data was corrupted.
But I also have DVDs which have been kept in folders and they seem to last about 10 years or so - but these are branded well known ones (DataWrite and Phillips).
Lesser brands or generic (Poundland) etc do not keep anywhere near as long even if you get a completely good write.
Blu-Ray discs which use ablative writing last very long and do not seem to be corrupted by sunlight (as you would expect) but for longevity avoid the ones which use dyes.
I wouldn't use SD cards (or indeed any memory storage) for long term archival purposes because they can ALL suffer from slow degradation over the years - the best bet is at least TWO complete backups of all important data and at least one should be somewhere separate to the first.
My photos for instance are backed up to several mediums - the cloud, DVD.s, HDDs ets.
If you store on magnetic HDDs I would write all data to a new HDD at least every five years to ensure the data stays relatively fresh and trouble free.