Ir al contenido

EntityDiagram

Las tablas y cómo apuntan unas a otras: cada tabla es una caja con sus columnas y tipos, las claves marcadas, y una línea desde cada columna que apunta a la clave de otra tabla.

import { EntityDiagram, EntityDiagramSkeleton } from '@sypnia/ui/react'

En esta página
  1. Las tablas de una tienda
  2. Skeleton
  3. Cuándo usarlo
  4. Para todos
  5. Props

Las tablas de una tienda

customers

  • PKiduuid
  • emailtext
  • nametext?
  • created_attimestamptz

orders

  • PKidbigint
  • customer_iduuid
  • totalnumeric
  • statetext

order_items

  • PKidbigint
  • order_idbigint
  • product_idbigint
  • quantityint

products

  • PKidbigint
  • nametext
  • pricenumeric
  • orders.customer_id → customers.id orders.customer_id apunta a customers.id
  • order_items.order_id → orders.id order_items.order_id apunta a orders.id
  • order_items.product_id → products.id order_items.product_id apunta a products.id
Código
import { EntityDiagram } from '@sypnia/ui/react';

// Each table with its columns; a line from every column that points to another table's key. On phones the boxes
// stack and the relations are listed under them.
export default function Shop() {
  return (
    <EntityDiagram label="Tables of the shop" columns={3} entities={[
      { name: 'customers', column: 1, row: 1, columns: [{ name: 'id', type: 'uuid', primaryKey: true }, { name: 'email', type: 'text' }, { name: 'name', type: 'text', nullable: true }, { name: 'created_at', type: 'timestamptz' }] },
      { name: 'orders', column: 2, row: 1, columns: [{ name: 'id', type: 'bigint', primaryKey: true }, { name: 'customer_id', type: 'uuid', references: 'customers.id' }, { name: 'total', type: 'numeric' }, { name: 'state', type: 'text' }] },
      { name: 'order_items', column: 3, row: 1, columns: [{ name: 'id', type: 'bigint', primaryKey: true }, { name: 'order_id', type: 'bigint', references: 'orders.id' }, { name: 'product_id', type: 'bigint', references: 'products.id' }, { name: 'quantity', type: 'int' }] },
      { name: 'products', column: 2, row: 2, columns: [{ name: 'id', type: 'bigint', primaryKey: true }, { name: 'name', type: 'text' }, { name: 'price', type: 'numeric' }] },
    ]} />
  );
}

Skeleton

Código
import { EntityDiagramSkeleton } from '@sypnia/ui/react';

// The tables while they load.
export default function Skeleton() {
  return <EntityDiagramSkeleton tables={3} />;
}

Cuándo usarlo

Úsalo cuando

  • El esquema de una base de datos, en la consola o en la documentación.
  • Ubica las tablas con column y row para que las líneas no se crucen.

No lo uses cuando

  • Las columnas de una tabla en detalle: usa SchemaViewer.

Para todos

  • Cada tabla es una región con el número de columnas en su nombre; las claves se dicen en palabras.
  • Las relaciones se listan bajo las cajas, así los celulares y los lectores de pantalla las tienen sin las líneas.

Props

EntityDiagramTipoPor defecto
entitiesobligatorio Entity[]
labelobligatorio string
columns number 3
EntityDiagramSkeletonTipoPor defecto
columns number 3
tables number 3
  1. Las tablas de una tienda
  2. Skeleton
  3. Cuándo usarlo
  4. Para todos
  5. Props

    Busca páginas, secciones y términos