Finding the Data Relationship that Works for You

Brian Cornelius
Sep 3, 2018 · 2 min read

SQL Schema Design

Structured query language (SQL) allows for the easy creation and accessing of well-organized databases. To reduce necessary storage space, SQL allows for the creation of multiple cross-referencing data tables. The structure of the database (the collection of tables) reflects the relationship being displayed. This short will explore three notable datatypes.

One-to-One

One-to-one tables are the least common of the three because there is little benefit to keeping directly related data on multiple tables. For example, keeping track of unique user ids with a single table that contains all the information is more efficient than having one table of usernames and a separate table of ids that reference each other via id numbers.

Many-to-One

A many-to-one table is an excellent way to depict a set of relationships wherein each member of one group is associated with several members of another group. Rather than replicating data, one group can reference the other through a unique id.

Many-to-Many

A many-to-many relationship is one where several members of one table are related to several members of another table. In this case, it is best to form distinct tables for each data set along with a separate table that only tracks these relationships by way of their unique reference numbers.

SQL is a powerful tool that can help organize and store uniformly tracked data in an easy to access way. The ability to cross-reference data easily is important for the off-site storage of large quantities of data.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade