O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

There's more...

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required