> For the complete documentation index, see [llms.txt](https://sena-ceet.gitbook.io/2252819-trimestre-2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sena-ceet.gitbook.io/2252819-trimestre-2/base-de-datos/bases-de-datos/relacion/uno-a-mucho.md).

# Uno a Mucho

## Uno a muchos NO identificable

![](/files/-MZxN6nhbWrII9HXDPBG)

```sql
CREATE TABLE nivel_formacion (
  nivel  varchar(40) NOT NULL, 
  estado varchar(40) NOT NULL, 
  PRIMARY KEY (nivel));


CREATE TABLE programa (
  codigo  varchar(50) NOT NULL, 
  version varchar(40) NOT NULL, 
  nombre  varchar(500) NOT NULL, 
  sigla   varchar(40) NOT NULL, 
  estado  varchar(40) NOT NULL, 
  nivel   varchar(40) NOT NULL, 
  PRIMARY KEY (codigo, 
  version));
ALTER TABLE programa ADD CONSTRAINT fk_nifo_prog FOREIGN KEY (nivel) REFERENCES nivel_formacion (nivel);
```

## Uno a mucho identificable

![](/files/-MZxQOs3DfW55skjMHCz)

```sql
CREATE TABLE tipo_documento (
  sigla            varchar(10) NOT NULL, 
  nombre_documento varchar(100) NOT NULL UNIQUE, 
  estado           varchar(40) NOT NULL, 
  CONSTRAINT pk_tipo_documento 
    PRIMARY KEY (sigla));
	
	CREATE TABLE cliente (
  numero_documento varchar(50) NOT NULL, 
  sigla            varchar(10) NOT NULL, 
  primer_nombre    varchar(50) NOT NULL, 
  segundo_nombre   varchar(50), 
  primer_apellido  varchar(50) NOT NULL, 
  segundo_apellido varchar(50), 
  login            varchar(50) NOT NULL UNIQUE, 
  CONSTRAINT pk_cliente 
    PRIMARY KEY (numero_documento, 
  sigla));
	ALTER TABLE cliente ADD CONSTRAINT fk_tipo_documento FOREIGN KEY (sigla) REFERENCES tipo_documento (sigla);
```

## Uno a mucho recursiva no identificable

![](/files/-MZxCVthZVRN7fCSlAcj)

```sql
CREATE TABLE categoria (
  numero_categoria SERIAL NOT NULL, 
  categoria_padre  int4 NOT NULL, 
  nombre_categoria varchar(100) NOT NULL, 
  PRIMARY KEY (numero_categoria));
ALTER TABLE categoria ADD CONSTRAINT fk_categoria FOREIGN KEY (categoria_padre) REFERENCES categoria (numero_categoria):

```

## Uno a mucho recursiva identificable

No EXISTE no se puede hacer, genera problemas en el motor


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sena-ceet.gitbook.io/2252819-trimestre-2/base-de-datos/bases-de-datos/relacion/uno-a-mucho.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
