Skip to Main Content

Write Great SQL Office Hours

Free tips and training every month! Subscribe for reminders and more from Office Hours. FAQ

Header container

November 21, 2023

14:00 UTC   Start Times Around the World

Subscribe to be notified of changes to sessions and give us feedback!

Having trouble watching the video on this page? Open the video in your browser.


Help me create the perfect database schema
You face many choices when you create database tables. For example, should you use:

- Sequences or GUIDs for primary key values?
- Blockchain tables or triggers for preventing updates?
- A separate table for addresses or store them inline?

In this interactive session, we discussed how to create tables to store invoice details. The audience suggested the pros and cons of each option, then voted for their favourites. We finished by building the tables using the options with the most votes.

Watch us to design the perfect database schema & let us know which options you would choose in the comments!

Highlights include:

- 03:20 - Surrogate keys: sequences vs GUIDs
- 12:50 - Prevening updates: blockchain tables vs triggers
- 22:40 - Storing monetary values: Major & minor vs minor only
- 30:50 - Invoice totals: storing on header vs calculating
- 38:00 - Storing address details: inline in invoice tables or separate address table
- 44:15 - Demo creating schema based on audience votes
- 52:10 - Demo of blockchain vs triggers to prevent updates
- 58:05 - Demo of sequences vs GUIDs for primary keys
- 1:00:50 - Demo of storing money in major & minor or minor units only
- 1:03:10 - Demo of storing vs calculating invoice totals
- 1:06:00 - Summary of options and Chris' preferred choices

Your Experts

    Chris Saxon

    Chris Saxon   

    Chris Saxon is an Oracle Developer Advocate and quizmaster on Dev Gym. His job is to help you get the best out of the Oracle Database and have fun with SQL! He's also part of the answer team on Ask TOM and creates YouTube videos at The Magic of SQL channel.