educative.io

Design Youtube - Design DB Schema - Was id designed correctly?

I noticed that as a type of id field was used INT, weird isn’t it? There was a topic about the id sequencer or approach to generate unique and cheap ids, but we don’t use it there. Even simple Long provide enough capacity.

Maybe I got it wrong, but if we have 500 hours of uploading videos per minute each of them 5 minutes, that means that we have (500 * 60) / 5 = 6000 rows per minute and if we assume MAX_INT = 2147483647, then T(min) = max_int % 6000 => T(min) = 357913 minutes to exhaust all ints values, or
T(days) = 357913 / 60 / 24 => T(days) = 248.55 days or 8.2 months to exhaust positive ids of INT.

Does it make sense to use Long as Type for ID fields?


Course: https://www.educative.io/collection/10370001/4941429335392256
Lesson: https://www.educative.io/collection/page/10370001/4941429335392256/5334361548783616