The enums table should not have a duplicate combination of type-value because this might lead to confusion, especially when the code that populates the traffic_unit table looks up the necessary id in the enums table. Instead of the one value that is expected, the query will return two. Which one to pick, then? To avoid duplication, we can add a unique constraint to the enums table:
ALTER TABLE enums ADD CONSTRAINT enums_unique_type_value UNIQUE (type, value);
Now if we try to add a duplicate, the database will not allow it.
Another important consideration of database table creation is whether an index has to be added. An index is a data structure that helps to accelerate data searches in the table without having to check ...