PHP Classes

PHP PostgreSQL Show Table Relationships: Find relationships between PostgreSQL tables

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-10-26 (11 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 35 All time: 11,002 This week: 74Up
Version License PHP version Categories
postgresql-relations 1.0GNU General Publi...8Databases, Tools, PHP 8
Description 

Author

This package can find relationships between PostgreSQL tables.

It can connect to a given PostgreSQL database and perform SQL queries to find relationships between two tables.

The package returns a string that details the relationships found between tables.

Innovation Award
PHP Programming Innovation award nominee
October 2023
Number 4
Many software projects use relational databases like PostgreSQL to store and retrieve information used by those projects.

As the projects are developed, database schema usually evolves to store more information structures to support new features.

That database schema evolution process usually includes adding more database tables and relationships between them.

Naturally, developers remember the whole table structure of complex databases.

This package implements a tool that allows developers to remember the relations between tables of a PostgreSQL database.

This possibility helps developers to be better prepared to develop new features that involve database table relationships.

Manuel Lemos
Picture of Moisés Lima
  Performance   Level  
Name: Moisés Lima <contact>
Classes: 5 packages by
Country: Brazil Brazil
Age: 36
All time rank: 3501274 in Brazil Brazil
Week rank: 192 Up14 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 3x

Example

#!/usr/bin/php -q
<?php

require_once 'vendor/autoload.php';

use
TheMoiza\PostgresqlRelationshipFinder\RelationshipFinder;

$RelationshipFinder = new RelationshipFinder;

echo
$RelationshipFinder->find(
   
$tableDown = ['public' => 'order'],
   
$tableTop = ['public' => 'users'],
   
$connection = [
       
"DB_HOST" => "127.0.0.1",
       
"DB_PORT" => "5432",
       
"DB_DATABASE" => "database",
       
"DB_USERNAME" => "user",
       
"DB_PASSWORD" => "123",
       
"DB_SCHEMA" => "public"
   
]
);


Details

Postgresql Relationship Finder

Postgresql Relationship Finder is a tool for discovering and visualizing the relationships between database tables in PostgreSQL.

Table of Contents

Features

  • Discover the relationships between tables using foreign keys.
  • Easily navigate complex database schemas.
  • Optimize SQL queries by understanding data relationships.

Getting Started

#!/usr/bin/php -q
<?php

require_once 'vendor/autoload.php';

use TheMoiza\PostgresqlRelationshipFinder\RelationshipFinder;

$RelationshipFinder = new RelationshipFinder;

echo $RelationshipFinder->find(
	$tableDown = ['public' => 'users'],
	$tableTop = ['public' => 'budget'],
	$connection = [
		"DB_HOST" => "127.0.0.1",
		"DB_PORT" => "5432",
		"DB_DATABASE" => "database",
		"DB_USERNAME" => "user",
		"DB_PASSWORD" => "pass",
		"DB_SCHEMA" => "public"
	]
);

Prerequisites

Before you begin, ensure you have met the following requirements:

  • PostgreSQL installed and configured.
  • PHP for running the Postgresql Relationship Finder script.

Installation

  1. Clone this repository.
    git clone https://github.com/themoiza/postgresql-relationship-finder.git
    

  Files folder image Files (7)  
File Role Description
Files folder imagesrc (2 files)
Accessible without login Plain text file cli.php Example Example script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files (7)  /  src  
File Role Description
  Plain text file RelationshipFinder.php Class Class source
  Plain text file RelationshipFinderException.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:35
This week:0
All time:11,002
This week:74Up