DEV Community

Cover image for Database Design
brvarner
brvarner

Posted on

Database Design

Today we focused on database design, specifically exploring the concepts that drive relational databases.

What's a relational database?

It's a collection of tables storing different data pieces that refer to one another to form a complete picture of something. By referencing other tables, we can stick to one value per field design principles while adding organized complexity to our entries.

What?

Today, we used a film database as an example. This database had tables for films, actors, and directors.

You can't just include a list of every actor in a movie in the films table, so you need a way to keep track of each film's cast. This is where a one-to-many join table comes into play.

You can create a table where each record is a film ID, an actor's ID, and the name of the role they played. A query to this table can then return each actor ID matched with a single film's ID and provide a comprehensive list of every actor in that film.

This way, you can keep track of the dozens of actors that make up a film's cast without bogging down every table.

Conclusion

This form of database design applies to SQL, it's been a while since I've studied SQL, so it was nice to get a refresher.

Image of Stellar post

Check out Episode 1: How a Hackathon Project Became a Web3 Startup 🚀

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Explore this insightful post in the vibrant DEV Community. Developers from all walks of life are invited to contribute and elevate our shared know-how.

A simple "thank you" could lift spirits—leave your kudos in the comments!

On DEV, passing on wisdom paves our way and unites us. Enjoyed this piece? A brief note of thanks to the writer goes a long way.

Okay