Is it a good idea to have a database row that represents an unknown value within a system [closed]

We have two systems, System A imports a list of sports events from system B, it only wants to import the events we will be providing live data for, the filter used to hide events that we are not providing data for is if the event has a referee assigned to it.

The problem with this is that we don’t know who the referee will be for particular events but we know there will be one so someone has created a referee with the name TBC and assigned it to a bunch of events so they will get imported.

Now there is a request to be able to mass assign this TBC referee to multiple events to save our operations staff from having to manually assign the referee for each event one by one.

This to me seems like a very bad idea, I don’t like the idea of a referee called TBC in the first place but i can’t really explain why, just seems like an anti pattern to me.

Can someone help me out and explain if it is a bad idea or not and why ?

3

Let us assume there’s an EVENT table and a REFEREE table, and that the first one has a PK (referee_id) which refers to REFEREE‘s PK (referee_id).

Then one “TBC” referee (not a real person), is inserted in table REFEREE, so any event that has no referee assigned a the moment of insertion can at least be assigned the code of that imaginary referee.

That doesn’t look like a very good idea to me, compared to simply leaving the FK in it’s null state:

  • As FKs must accept null, there’s always the possibility of having events with “TBC” as well as others with nothing (null). That means code must handle both situations everywhere. For example a report listing all events with no referees should consider both cases.

My recomendation is:

Create a view that shows the literal “TBC” whenever there’s no assigned referee, like this:

create view v_events as
select
    e.event_name,
    e.event_date,
    nvl(r.referee_name,'TBC') as referee_name
from
    event e left join referee r (on e.referee_id = r.referee_id);

In the case the referee is not it’s own table but just a text column in EVENT:

create view v_events as
select
    e.event_name,
    e.event_date,
    nvl(e.referee_name,'TBC') as referee_name
from
    event e;

Note: NVL is an Oracle function, substitute with an equivalent function in your RDBMS, like COALESCE in Postgres.

Have all code select that view instead of the real table. That way everyone will think there’s a “TBC” referee assined by default.

There seems to be too many business rules that rely on the existence of a referee id: Who is the ref and whethere or not this event is streamed. For all the streamed/non-refereed events, the field is null. It would be difficult to look at your database and make this determination.

I don’t know how much of your data structure you could change, but this holding ID for a TBD referee is going to have to be addressed in other queries as well.

Ideally, there should be some sort of table:

EventReferee

  • EventID
  • RefereeID

    • a lot of other data can be put here that may typically also be null in your Event table: assignment date, etc.

This way, you would have a record in this table to designate those that do not provide a live feed/have a referee, but still may or may not have a referee ID assigned.

A query for who still needs a referee assigned is very simple by checking for null.
A query for events that have a referee will have this record related to the event.
A query for events that a streamed will not have a record in the EventReferee table.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Is it a good idea to have a database row that represents an unknown value within a system [closed]

We have two systems, System A imports a list of sports events from system B, it only wants to import the events we will be providing live data for, the filter used to hide events that we are not providing data for is if the event has a referee assigned to it.

The problem with this is that we don’t know who the referee will be for particular events but we know there will be one so someone has created a referee with the name TBC and assigned it to a bunch of events so they will get imported.

Now there is a request to be able to mass assign this TBC referee to multiple events to save our operations staff from having to manually assign the referee for each event one by one.

This to me seems like a very bad idea, I don’t like the idea of a referee called TBC in the first place but i can’t really explain why, just seems like an anti pattern to me.

Can someone help me out and explain if it is a bad idea or not and why ?

3

Let us assume there’s an EVENT table and a REFEREE table, and that the first one has a PK (referee_id) which refers to REFEREE‘s PK (referee_id).

Then one “TBC” referee (not a real person), is inserted in table REFEREE, so any event that has no referee assigned a the moment of insertion can at least be assigned the code of that imaginary referee.

That doesn’t look like a very good idea to me, compared to simply leaving the FK in it’s null state:

  • As FKs must accept null, there’s always the possibility of having events with “TBC” as well as others with nothing (null). That means code must handle both situations everywhere. For example a report listing all events with no referees should consider both cases.

My recomendation is:

Create a view that shows the literal “TBC” whenever there’s no assigned referee, like this:

create view v_events as
select
    e.event_name,
    e.event_date,
    nvl(r.referee_name,'TBC') as referee_name
from
    event e left join referee r (on e.referee_id = r.referee_id);

In the case the referee is not it’s own table but just a text column in EVENT:

create view v_events as
select
    e.event_name,
    e.event_date,
    nvl(e.referee_name,'TBC') as referee_name
from
    event e;

Note: NVL is an Oracle function, substitute with an equivalent function in your RDBMS, like COALESCE in Postgres.

Have all code select that view instead of the real table. That way everyone will think there’s a “TBC” referee assined by default.

There seems to be too many business rules that rely on the existence of a referee id: Who is the ref and whethere or not this event is streamed. For all the streamed/non-refereed events, the field is null. It would be difficult to look at your database and make this determination.

I don’t know how much of your data structure you could change, but this holding ID for a TBD referee is going to have to be addressed in other queries as well.

Ideally, there should be some sort of table:

EventReferee

  • EventID
  • RefereeID

    • a lot of other data can be put here that may typically also be null in your Event table: assignment date, etc.

This way, you would have a record in this table to designate those that do not provide a live feed/have a referee, but still may or may not have a referee ID assigned.

A query for who still needs a referee assigned is very simple by checking for null.
A query for events that have a referee will have this record related to the event.
A query for events that a streamed will not have a record in the EventReferee table.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật