sql - Normalize one-to-one boolean relation -
is a large table products
in my product model; Boolean flag disabled
I need to add. Generally I will just add a new area to the current table. But the use of this feature will be very low, and given the number of records in the table, this new field will create display and make an unnecessary hit at the disk space.
So I decided to do one type of NF generalization one-to-one relationship (ie foreign key referenced products
; reference to this field; Not that this is actually 1 NF - this is a part of my question). But I do not really need the true
and false
values for the disabled
attribute of each product, because it shows that the table size of the relationship The size will be equal to products
so there is no need in the respective area of the table. So my schema is:
create table products (ID INT primary key, name VARCHAR); Create tablet disabled_products (product_id not INT; contract FK_product foreign key (product_id) reference product (ID) on daylight cascade);
(Bella around).
In this way, I get what I wanted - this value is stored only for those rare cases when the flag is set. The flag behind the curtain is not shown by the table column, but by a very visible presence in the disabled_products
for a given product.
Just want to know if I am doing right?
What are the possible drawbacks of this kind of design, if any?
Is it appropriate for the relational model ( this mean that I normally mean a table with a common foreign key column in general)? And if so, how do you say this solution in terms of RDB science?
People often ask themselves if they should split a table or just make a big table I will talk to the general argument below in your case, it is purely a well-defined performance calculation.
Professionals & amp; Contrary to your solution 1) Q: Even though the records have been lessly disabled, you will need to join every query in this table which requires an active record.
2) CON: Why is the space saving 1 byte, which is most likely negligible, why bother.
3) PRO: This prevents you from changing the table which can be a problem for you.
Recommendation: Looking at the above pros and cons, I only recommend adding fields to my table. This is just a byte.
In general, people split their tables vertically when it is impractical to modify the table as well or when there are different classes of records, each of which sets the specific areas, or For reasons of performance they want to split their table.
Comments
Post a Comment