New ACM paper, free-tier cloud, and open-source license

TypeDB Blog


Introducing the Type Theory and Polymorphic Foundations of TypeDB

In the last 40 years since relational algebra and SQL, databases have yet to provide more powerful abstractions to express more advanced logic.

Haikal Pribadi


When we look at the evolution of databases in the last 40 years since relational algebra and SQL, even though there has been incredible progress in performance and operational capabilities, databases have yet to provide more powerful abstractions to express more advanced logic. Database models have failed to keep up with the rapid evolution of programming languages, and modern applications must use complex layered architectures to manage data as a result.

Relational databases lack the expressivity to model polymorphism, and eliminating the schema in NoSQL databases prevents declarative data retrieval. Meanwhile, modern programming languages have become incredibly declarative, empowering engineers to quickly write safe and expressive code backed by static type checking and abstract data constructs.

A lot of the progress in modern programming languages can actually be traced to powerful ideas from Type Theory — the study of type systems and how they formally govern mathematical and logical systems. For example, in Rust, the affine type system that governs “borrowing”, or pattern matching definitions that are used to restructure algebraic types, are both real-world applications of type-theoretic principles in today’s programming languages.

However, type-theoretic thinking that has significantly influenced the evolution of modern programming languages in the last 20 years, have yet to be fully leveraged in the database field.

With modern type-theoretic mathematics at our disposal, how would we re-think and re-design the foundations of modern databases in the best possible way?

Answering this question is what led to building a new kind of database: TypeDB — a type-theoretic database which yields a polymorphic data model and query language. In the past month, we’ve published a brief introduction to our philosophy and the novel features it yields in TypeDB and TypeQL. Over the next month, we will be sharing with you a larger body of research on the underlying theory and philosophy behind our work, broken into 4 chapters — each in the form an in-depth technical article and lecture.


#1 Type Theory as a the Unifying Foundations for Modern Databases

In this lecture, we will give a first comprehensive answer to the question above, and take you on a whirlwind tour of how to synthesize type-theoretic thinking with conceptual data models, and the repercussions that this synthesis has. In more detail, we will:

  • Describe the mathematical origins of the most prominent database paradigms.
  • Learn how contemporary mathematics re-thinks these foundations with type theory.
  • Give a crash in type theory, tailored to non-mathematicians
  • Explain how conceptual modeling theory enables ‘highly generalizable data models’.

And finally, we will combine the above to synthesize conceptual data models and type theory to create a new ‘unified’ foundation for the modern database.


#2 Why We Need a Polymorphic Database

In this lecture, we’ll examine the historical context and design philosophies behind the relational, document, and graph database paradigms to understand their strengths and weaknesses. We’ll look at the different strategies that database engineers employ to work around translating polymorphism from their object models. We’ll explore a polymorphic object model for a simple filesystem and see how the lack of expressivity inherent in current databases leads to fundamentally brittle application architectures. Finally, we’ll attempt to answer the question: why do we need a polymorphic database? Join this lecture and learn more about:

  • The strengths and weaknesses of current database paradigms.
  • How databases engineers work around polymorphism in data models.
  • How current databases lead to fundamentally brittle application architectures.

#3 TypeDB: the polymorphic database

In this lecture, we introduce TypeDB’s polymorphic modeling and querying capabilities. We’ll begin by introducing the three fundamental types of polymorphism, and examine some examples of polymorphic queries in natural language. Next, we’ll build a polymorphic TypeDB schema that models a simple filesystem featuring inheritance and interfaces. We’ll then explore the different ways that inheritance, interface, and parametric polymorphism can be utilized and combined in TypeQL query patterns. Finally, we’ll see how declarative polymorphic querying allows us to extend the schema without rewriting queries and trivially maintain application architectures. Join this lecture and learn about:

  • How the three kinds of polymorphism manifest in natural data domains.
  • TypeDB’s unique modeling and querying capabilities as the polymorphic database.
  • The impact that a polymorphic database has on architecture maintenance.

#4 The Polymorphic Data Model of TypeDB

TypeDB follows a different approach: instead of providing many different modeling paradigms, it provides a single, highly expressive model, that is natively compatible with many of the models listed above. TypeDB’s model is based on a polymorphism-enhanced conceptual approach: which, as in traditional conceptual data models, structures data into three natural categories of ‘entities’ (independent object types), ‘relations’ (dependent object types), and ‘attributes’ (dependent or independent value types), but in addition, provides native facility for expressing inheritance and interface polymorphism of these types. In this lecture, we will learn how to think in TypeDB’s polymorphic data model. In particular, we will touch on:

  • The key ingredients of the polymorphic entity-relation-attribute model.
  • How other models can be easily translated into TypeDB’s model.
  • How to put polymorphism to efficient use in your everyday life.

That’s all for now. In next announcement, we’ll share with you the various improvement on TypeDB that went out in the last 5 major releases in the past few months, along with the launch of TypeDB Cloud going public next month! If you want to hear more of our updates on TypeDB, subscribe to our newsletter.

Share this article

TypeDB Newsletter

Stay up to date with the latest TypeDB announcements and events.

Subscribe to Newsletter

Further Learning

The Theory of TypeQL

TypeQL is directly built on the principles of modern programming language theory, which distill how we intuitively interact with computers using simple, yet formal, structures: types.

Read article

Type Theory Fundamentals

Discover the powerful unification of paradigms backed by modern type-theoretic mathematics, laying a novel foundation for modern database applications.

Read article

Crash course

Explore TypeDB in 25 queries, showcasing core and advanced features with easy and intuitive examples.

Read docs

Feedback