database - Printing the names of all the people greater than age 18? -
this pretty question posed me recently. suppose have hypothetical (insert favorite data storage tool here) database consists of names, ages , address of people residing on planet. task print out names of people age greater 18 within html table. how go doing that? lets hypothetically population growing @ rate of 1200/per second , database updated accordingly(don't ask how). strategy print names of these people , addresses on html table?
storing ages in db tables sounds recipe trouble me - impossible maintain. better off storing birth dates, building index on column/attribute.
you have initial dump of table display. calculate date 18 years ago (let's
d0) , use query person born earlier that.use db triggers receive notifications deaths, can remove them table immediately.
since people older (unfortunately?), can use ranged queries new additions (i.e. people become 18 years old since yo last queried table). e.g. if want update display next day, issue query people born in day
d0 + 1- no need request whole table again.you prefetch people reach 18 years of age next day, keep entries in memory, , add them display @ exact moment reach age.
btw, 2kb of data each person, 18tb database (assuming 50% overhead). beefed server should able handle kind of db size. on other hand, thought of 12 tb html table terrifies me...
oh, , beware of timezone , dst issues - time such relative thing these days...
Comments
Post a Comment