Subject: | Displaying edge labels (solution included) |
I find it useful to have names with each edge, that display both tables
& columns.
I've managed to do that the following way. This might be useful to
others and could be an option. It needs however changes in both
::FromSchema & GraphViz::DBI
in ::FromSchema, new simplified is_foreign_key (that works with Oracle) :
sub is_foreign_key
{
my ($self, $table, $field) = @_;
unless ($self->{foreign_key}{$table})
{
my $keys_query = $self->get_dbh()->foreign_key_info(undef, undef,
undef, undef, undef, $table);
if ($keys_query)
{
while (my $rh=$keys_query->fetchrow_hashref())
{
$self->{foreign_key}{$table}{$rh->{FK_COLUMN_NAME}}=[
$rh->{UK_TABLE_NAME}, $rh->{UK_COLUMN_NAME} ];
}
}
}
return $self->{foreign_key}{$table}{$field};
}
in ::DBI, modified graph_tables (with new syntax for GraphViz along the
way), it needs :
if (my $dep = $self->is_foreign_key($table, $field)) {
my ($deptable,$depcol)=@$dep;
$self->{g}->add_edge($table => $deptable, label =>
sprintf('%s.%s => %s.%s',$table,$field,$deptable,$depcol) );
}
HTH,