Relation between/among Tables/Entities: Definition and Condi

Click For Summary

Discussion Overview

The discussion revolves around the concept of "relation" between database tables, specifically focusing on the definition and conditions under which tables are considered related. Participants explore various scenarios of relationships, including one-to-one and one-to-many relationships, and the implications of foreign keys in these contexts.

Discussion Character

  • Conceptual clarification
  • Debate/contested
  • Technical explanation

Main Points Raised

  • One participant proposes that tables X and Y are related if attributes in Y provide context for attributes in X, formalized by the presence of a foreign key in Y that references a primary key in X.
  • Another participant challenges this by stating that the existence of a foreign key does not necessarily mean the other table is required, suggesting that one-to-many relationships can exist where Y may not have entries for every X.
  • A subsequent reply emphasizes that for a relationship to be valid, the foreign key in Y must correspond to an existing primary key in X, but acknowledges that Y can have zero, one, or multiple records for the same foreign key.
  • Participants discuss the normalization of tables, indicating that if a table has multiple entries for a worker, it should be separated into a new table with a foreign key to maintain the relationship.
  • There is a request for examples where a foreign key might have zero records in the related table, indicating a need for further exploration of this scenario.

Areas of Agreement / Disagreement

Participants express differing views on the necessity of the existence of records in related tables, with some asserting that relationships can exist without mandatory entries in the foreign key table. The discussion remains unresolved regarding the conditions under which tables are definitively considered related.

Contextual Notes

Participants assume that tables have been normalized, which influences their definitions and examples of relationships. The discussion does not resolve the implications of normalization on the relationship definitions.

WWGD
Science Advisor
Homework Helper
Messages
7,806
Reaction score
13,120
Hi All,
My apologies, I think I may have asked this question already, but I could not find it. Here it goes:

I have seen the usage of the word 'relation', specifically a relation between tables but I have not seen a formal definition. From what I understand, tables X,Y are related to each other if some attributes A_X used in X need some of the attributes A_Y in Y in order to be "fully understood" , meaning some attribute A_yi in Y is needed as context to make sense of some attribute A_Xj in X. Formally this is expressed by the fact that an attribute in Y is used as a FK (Foreign Key) in X.

As an example, I guess we could have:
X is "Workers": Worker_Num (PK), Worker_FName, Worker_LName, Worker_DOB and

then Y could be for info on workers:

Work_Info: Work_ID , Work_HourlyPay, Work_Skill (Assuming each has just one skill), Work_Hrsweek (Assuming these are constant), Worker_Num (FK).

Then Y's existence and meaning depend on X. So we say X,Y are related? And this is made formal by the fact that Y contains the FK Worker_Num ?

Is this correct? Is there more/less to it than this?

Thanks.
 
Technology news on Phys.org
I wouldn't say that the other table is always required. Your examples are mainly one-to-one relationships. You could also have a WorkerPhone that may not have any entries for a worker or may have multiple entries (one-to-many).
 
  • Like
Likes   Reactions: WWGD
Borg said:
I wouldn't say that the other table is always required. Your examples are mainly one-to-one relationships. You could also have a WorkerPhone that may not have any entries for a worker or may have multiple entries (one-to-many).

Thanks, Borg, but then when do I say that two tables are related? I guess I am assuming the tables have been normalized, so if WorkerPhone had multiple entries wouldn't it have become (at least part of ) a new table?
 
The way I use it is that two tables are related when the foreign key in your Y table has to correspond to an existing primary key in your X table.
As Borg said, the Y table can contain 0,1 or more records with the same value in the foreign key, but that value must correspond to an existing primary key in the X table.

The X table could be your Customers table, with primary key cust_pk.
The Y table could be your Contacts table, listing various contacts related to customers. Contacts has a cust_pk foreign key (the name is immaterial), and the value entered in that field must correspond to an existing cust_pk in Customers.
 
  • Like
Likes   Reactions: WWGD
WWGD said:
Thanks, Borg, but then when do I say that two tables are related? I guess I am assuming the tables have been normalized, so if WorkerPhone had multiple entries wouldn't it have become (at least part of ) a new table?
Yes they would have to be in a separate table. You would then need a foreign key to the main worker table to establish the relationship. When you build the tables you can enforce the relationships so that you can't build a phone record for a worker FK that doesn't exist.
 
  • Like
Likes   Reactions: WWGD
Samy_A said:
The way I use it is that two tables are related when the foreign key in your Y table has to correspond to an existing primary key in your X table.
As Borg said, the Y table can contain 0,1 or more records with the same value in the foreign key, but that value must correspond to an existing primary key in the X table.
Yes, thanks, of course I meant that the FK of Y has been exported to Y from X, possibly containing 0,1 or more records as you said. Can you think of a case where we would have 0 records?
Thanks.
 
Please ignore my previous, it has been answered.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
Replies
65
Views
5K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
3
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
5K
  • · Replies 0 ·
Replies
0
Views
2K