Тёмный

ENUM vs Check Constraint vs Lookup Table: Which Is Better? 

Database Star
Подписаться 56 тыс.
Просмотров 976
50% 1

📝 Bonus PDF: This ERD, descriptions of each table and column with sample data, and SQL scripts to create all of the tables on your own database: www.databasestar.com/dbdesign...
🎓 Learn how to design an effective database and create it using SQL: databasestar.mykajabi.com/edd...
There are a few ways you can restrict the values in a particular column.
In this video, I'll demonstrate the different ways you can do this, the advantages of each, and which method I recommend.
You'll learn about the ENUM concept in SQL, using a check constraint, and using a lookup table.
⏱ TIMESTAMPS:
00:00 - Our scenario
00:54 - Option 1: ENUM
02:43 - Option 2: Check Constraint
04:55 - Option 3: Lookup Table
🔗 VIDEO LINKS:
Scripts from this video: github.com/bbrumm/databasesta...

Наука

Опубликовано:

 

23 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 12   
@joel-rg8xm
@joel-rg8xm Месяц назад
I was always tempted to use ENUMs, I didn't know about CHECK constraints and I always thought LOOKUP TABLES were overkill in resources and performance, thanks for finally clearing it out for me.
@DatabaseStar
@DatabaseStar Месяц назад
Glad I could help!
@djtoon8412
@djtoon8412 2 месяца назад
i was designinf an RBAC for my system and came up with this tutorial.i was about to use enums role types but just one statement from why use lookup table changed my idea completely.Thank you
@DatabaseStar
@DatabaseStar 2 месяца назад
Thanks for sharing, glad to hear it helped you with your current work.
@openscriptsolution
@openscriptsolution Месяц назад
In addition to easier to maintain, using "lookup table" also will be easier to filter based on the certain business-logic from application side. For example, we can display only some specific options which have "active" status in add form, but display all options in edit form and list and view pages.
@DatabaseStar
@DatabaseStar Месяц назад
That's a good point - yes it is another benefit!
@epakadiongo3459
@epakadiongo3459 Месяц назад
Really like lookup and use it in many of my project
@DatabaseStar
@DatabaseStar Месяц назад
Glad to hear it helps!
@gauravsrivastava17
@gauravsrivastava17 Месяц назад
Lookup table is simple and easy to understand
@DatabaseStar
@DatabaseStar Месяц назад
That’s right, it is
@djtoon8412
@djtoon8412 2 месяца назад
can you please do a tutorial on uuid and big int.when to use one over the other on what usecases and is it safe to use uuid as primary keys.
@DatabaseStar
@DatabaseStar Месяц назад
Good idea! I can create a video on this.
Далее
Stop Complex SQL Date Logic and Use This Instead
13:32
When to Use a Subquery in SQL
8:50
Просмотров 31 тыс.
Stay on your way 🛤️✨
00:34
Просмотров 4,3 млн
doing impossible challenges✅❓
00:25
Просмотров 5 млн
Laravel: ENUM or INT with Foreign Key?
7:49
Просмотров 11 тыс.
How to Create SQL Code from a Database Design
13:47
Просмотров 8 тыс.
SQL Leetcode Problem Solved (Leetcode 183)
11:00
Movie Theatre Database Design: Step-by-Step
27:50
Просмотров 2,2 тыс.
Mysql Index Tutorial | [Simple Explanation] [2020]
6:56
SQL Data Analyst Project: Car Sales Data
34:28
Просмотров 1,7 тыс.
Database Indexing Explained (with PostgreSQL)
18:19
Просмотров 298 тыс.
MySQL: JOINS are easy (INNER, LEFT, RIGHT)
5:04
Просмотров 355 тыс.
iPhone, Galaxy или Pixel? 😎
0:16
Просмотров 1,1 млн