Splitting a named object into subsets and updating references to it. What is this process called?

I have a database query. I've named it roads_vw.

After the query had been used for some time, I realized that I needed to split the query into subsets: roads_with_spatial_column_vw and roads_without_spatial_colum_vw. Once the change was made, I needed to update anything that referenced the old query to use the name of one of the new queries.

This might seem a bit silly, but it happens all the time when I'm designing things, especially databases.

Is there a word or phrase that I could use to succinctly describe this situation?


Solution 1:

Yes, there is. It's called "partitioning". Colloquially you may also hear it called sharding. In PostgreSQL 10, you do it like,

CREATE TABLE roads (
  -- stuff
  has_x bool NOT NULL
) PARTITION BY LIST (has_x);

CREATE TABLE roads_with_x
   PARTITION OF roads
   FOR VALUES IN (true);

CREATE TABLE roads_without_x
   PARTITION OF roads
   FOR VALUES IN (false);

This is also nice because it obscures the underpinnings eliminating the need for you to write triggers.