There is a large table products. I need to add a boolean flag disabledto my product model. Usually I just add a new field to an existing table. But this attribute will be used very rarely, and given the number of records in the table, this new field will take an unnecessary blow to performance and disk space.
So, I decided to do something like 1NF normalization for a one-to-one relationship (i.e. move this field to another table with a foreign key binding products; I don't know if this is 1NF really - this is part of my question). But I really do not need values true, and falsefor each attribute disabled, because it means that the size relationship of the table is equal to the size products. Therefore, there is no need for a table value field. So my scheme is:
CREATE TABLE products (
id INT PRIMARY KEY,
name VARCHAR
);
CREATE TABLE disabled_products (
product_id INT NOT NULL,
CONSTRAINT fk_product FOREIGN KEY (product_id) REFERENCES products (id) ON DELETE CASCADE
);
( SQLFiddle to play with).
Thus, I get exactly what I wanted - the value is stored only for those rare cases when the flag is set. Behind the scenes, the flag is not represented by a table column, but by the presence of an entry disabled_productsfor this product.
I just want to know if I'm doing it right.
, ?
( it , )? , RDB?