views:

182

answers:

4

I'm doing some FK analysis of our tables by making a directed graph representing FK dependencies and then traversing the graph. In my code, I name everything using directed graph terminology, but I'd like to have something a bit more "user friendly" in the report.

In this scenario:

create table t1(a varchar2(20));
alter table t1 add constraint t1_fk foreign key(a) references t2(b);

t1.a must exist in t2.b. So, what words should I use in the blanks?

t1 is the _______ of t2.
t2 is the _______ of t1.

Many TIA!

+4  A: 

I'd say (things between brackets are optional, but I'd use them)

[Column a of] table t1 references [column b of] table t2

and

[Column b of] table t2 is referenced by [column a of] table t1

?

I'd also specify the action that happens on delete/update if any.

Column b of table t2 is referenced by column a of table t1. 
Deleting a record in table t2 will delete matching records on table t1
Vinko Vrsalovic
+1  A: 

I'd say something along the lines of

t1 is the master of t2. An ID must be in t1, before it can be mentioned in t2.
t2 is the slave of t1. It cannot refer to an ID that does not exist in t1.

Most non-technical people will grasp the master/slave terminology very intuitively.

Tomalak
+1  A: 

You could adopt the following sentence form:

  • Each t1 row must be linked to exactly one t2 row
  • Each t2 row may be linked with any number of t1 rows, or none
Tony Andrews
+3  A: 
t1 is the parent of t2.
t2 is the child of t1.

What is the audience for this? If it's people that understand a relational schema, then that will probably do. If it is non-technical people, then generally I have documented in my modelling tool (ERWin) the meaning of the relationships specifically.

InvoiceLineItem is a part of Invoice.
Invoice has one or more InvoiceLineItems.

Or:

User must belong to a Business.
Business has zero or more Users.
WW