the.moiza/postgresql-relationship-finder

探索、分析和可视化PostgreSQL中数据库表之间的关系

dev-master 2023-12-07 13:12 UTC

This package is not auto-updated.

Last update: 2024-09-27 15:20:09 UTC


README

Postgresql Relationship Finder 是一个用于发现和可视化 PostgreSQL 中数据库表之间关系的工具。

目录

功能

  • 使用外键发现表之间的关系。
  • 轻松导航复杂的数据库模式。
  • 通过理解数据关系来优化 SQL 查询。

入门

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

require_once 'vendor/autoload.php';

use TheMoiza\PostgresqlRelationshipFinder\RelationshipFinder;

$RelationshipFinder = new RelationshipFinder;

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

返回示例

在终端上执行 php 文件 cli.php。

$ php ./cli.php
··public.budget --> public.order --> public.cart --> public.users
··public.budget --> public.order --> public.users
··public.budget --> public.users

先决条件

在开始之前,请确保您已满足以下要求

  • 已安装和配置 PostgreSQL。
  • 用于运行 Postgresql Relationship Finder 脚本的 PHP。

安装

  1. 通过 composer。

    composer require the.moiza/postgresql-relationship-finder
  2. 克隆此存储库。

    git clone https://github.com/themoiza/postgresql-relationship-finder.git