TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Database Design for Google Calendar: A Tutorial

293 pointsby fagnerbrack10 months ago

13 comments

bigbones10 months ago
A random event from my calendar serializes to 740 bytes of iCalendar. An extremely busy calendar containing one event every 15 minutes 9am-5pm 7 days per week only contains 11680 entries for a full year, which works out to around 8MB.<p>Would suggest instead of designing a schema at all, a calendar is a good example of a problem that might be far better implemented as a scan. Optimizing an iCalendar parser to traverse a range of dumped events at GB&#x2F;sec-like throughputs would mean the above worst-case calendar could be scanned in single-digit milliseconds.<p>Since optimizing a parser is a much simpler problem to solve once than changing or adding to a bad data model after it has many users, and that the very first task involving your new data model is probably to write an iCalendar importer&#x2F;exporter anyway, I think this would be a really great trade off.
评论 #41044239 未加载
评论 #41044101 未加载
评论 #41045221 未加载
评论 #41044353 未加载
chandureddyvari10 months ago
This article about dealing with recurrence in applications was an eye-opener for me. Definitely recommend giving it a read. <a href="https:&#x2F;&#x2F;github.com&#x2F;bmoeskau&#x2F;Extensible&#x2F;blob&#x2F;master&#x2F;recurrence-overview.md">https:&#x2F;&#x2F;github.com&#x2F;bmoeskau&#x2F;Extensible&#x2F;blob&#x2F;master&#x2F;recurrenc...</a>
评论 #41044797 未加载
sensanaty10 months ago
The worst I have ever messed up during an interview was building a simple booking system that had to do recurring appointments. I never felt that lost and confused trying to accomplish something in code since my early university days lol<p>To this day whenever I have to work with anything datetime related I dread it, it just does not click in my head for some reason
评论 #41044901 未加载
评论 #41045254 未加载
munchler10 months ago
Modeling a system is an under-appreciated skill. In a new domain, however, this should really start with an analysis of the entire problem so as to capture both the static structure of the system (i.e. class model) and its dynamic behavior (i.e. use cases). Jumping directly into a static database model tends to leave out the dynamic behavior. That might be OK in a simple CRUD app like this one, but could be a big mistake in more complex systems.
评论 #41044695 未加载
评论 #41050939 未加载
LeonB10 months ago
I found this to be a good introduction and a well-chosen domain to demonstrate modelling.<p>The term “anchor” feels kind of weird to me, but the explanation is so concrete&#x2F;grounded (like an actual anchor) that I guess it works well enough.<p>The concept of defining the attributes via a question is solid, great way to get clarity quickly. Too often we jump to a minimal column&#x2F;property name without defining what question we’re trying to answer, and thus not shaking loose any ambiguity in the mind of the customer(s).
评论 #41050671 未加载
canucker201610 months ago
Timezones will bend your mind, especially around the transition times.<p>Assuming your timezone jumps forward one hour for daylight savings time and falls back one hour for transition to standard time...<p>When your time skips forward one hour, your 1 hour event may now be displayed as spanning two hours - the second hour will not be reachable&#x2F;does not exist.<p>When your time falls back one hour, your 1 hour event may now show as spanning 2 hours or 0 hours.<p>Timezones are a man-made construct so don&#x27;t hardcode values cause things will change...
评论 #41044141 未加载
评论 #41044128 未加载
pg_bot10 months ago
You don&#x27;t want to store two dates for an event. It&#x27;s easier to store the start time of the event and a duration for the event. This will make the logic for updating your events simple. You can always calculate the end time of the event based off the start and duration.
评论 #41050992 未加载
评论 #41044842 未加载
评论 #41045821 未加载
trwhite10 months ago
Years ago I worked on a calendar application with recurrence. After lots of research I settled on using RRules to represent this, which I was very pleased with. That initial work was when I was at an agency.<p>Later I joined the company full time and discovered to my amazement that a contractor from a different company had removed the RRules in favour of creating and destroying instances of events on the fly. It had no&#x2F;little fault tolerance so sometimes the script (which did other things that would sometimes fail) would fail to create new events. You&#x27;d have monthly recurring events with missing months.<p>I found it so frustrating that (after going through a lot of thought and research) that someone hadn&#x27;t put anywhere near as much effort into removing mine. It took just a few weeks at that company to realise that the CEO expected the Engineering team to pump out features (that nobody used) at his will and, in the uncertainty of the job market, sadly I stayed there for 2 years.<p>Unrelated footnote: After Googling them, it&#x27;s really sad to see what are blatantly fake reviews by the CEO on Glassdoor all written in the same style with nothing bad to say. I (and a bunch of other people I know who worked there) hated him, but the silver lining is that I wrote some of my best essays there. The CTO was hopeless too.
lichtenberger10 months ago
I once implemented the backend of a calendar and resource control for a low code platform.<p>The control is highly customizable, with a lot of views to chose from, daily, monthly, yearly... but also resource views (you can book resources with custom groupings, by plugin, by the resource-ID, whatever...), define &quot;plugins&quot; on the data sources, what&#x27;s the from- and to- columns, the title column, what&#x27;s the resource (may be from a foreign key &#x2F; 1:1 relationship or 1:N if it&#x27;s from a &quot;child&quot; data source or from the same data source&#x2F;table).<p>Furthermore I&#x27;ve implemented different appointment series, to chose from (monthly, weekly (which weekdays), daily...), which column values should be copied. Also appointment conflicts (or only conflicts if they book the same resource). You could also configure buffers before and after appointments where no other appointment can be.<p>That was a lot of fun and also challenge sometimes regarding time zones and summer&#x2F;winter time in Europe and so on :-)
roland3510 months ago
All I want in Google calendar is a log of changes to the calendar itself. Please add this to the database!
evnix10 months ago
Nicely done. This is one of those aspects which is not really touched on in most courses.<p>Will try to get my company to get a few copies of your book for each of our team member.
throwaway21110 months ago
Interesting.<p>How about edits, changes of time and location, who&#x27;s signed up and to which revision.
评论 #41043709 未加载
markus_zhang10 months ago
Interesting. I wonder what does a NoSQL one look like?
评论 #41044070 未加载
评论 #41050899 未加载
评论 #41044187 未加载
评论 #41044054 未加载