herencia y key

From: "Hibiki" <npolanco(at)uij(dot)edu(dot)cu>
To: "'Ayuda'" <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: herencia y key
Date: 2017-04-10 15:08:16
Message-ID: 009b01d2b20c$49112de0$db3389a0$@uij.edu.cu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola a todos, me gustaría que me aclararan una duda, cuando yo creo una tabla madre y dos hijas, ejemplo:

CREATE TABLE public.persona
(
id serial,
ci character varying(11) NOT NULL,
nombre name NOT NULL,
age integer NOT NULL,
sexo_id integer NOT NULL
);

CREATE TABLE public.cliente
(
-- Inherited from table persona: id serial,
-- Inherited from table persona: ci character varying(11) NOT NULL,
-- Inherited from table persona: nombre name NOT NULL,
-- Inherited from table persona: age integer NOT NULL,
-- Inherited from table persona: sexo_id integer NOT NULL,
tipo_cliente_id integer NOT NULL
)
INHERITS (public.persona)
);

CREATE TABLE public.programador
(
-- Inherited from table persona: id serial,
-- Inherited from table persona: ci character varying(11) NOT NULL,
-- Inherited from table persona: nombre name NOT NULL,
-- Inherited from table persona: age integer NOT NULL,
-- Inherited from table persona: sexo_id integer NOT NULL,
tipo_programador_id integer NOT NULL,
vincula_laboral boolean
)
INHERITS (public.persona)
);

A) Las relaciones con otras tablas, es decir las llaves foráneas, que son comunes las tengo que hacer:
1- Solo en la tabla madre.
2- En cada una de las tablas hijas.
3- O en las tres tablas, en la madre y ratificarla en cada hija.

B) La llave primaria la creo:
1- Las 3 tablas.
2- Solo en la madre.
3- O solo en las hijas.

C) Sería la PK de tipo serial en las 3 tablas o alguna combinación de integer en una/unas y serial en otra/otras?

Gracias desde ya.

Saludos

-
Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda(at)postgresql(dot)org)
Para cambiar tu suscripcin:
http://www.postgresql.org/mailpref/pgsql-es-ayuda

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Hibiki 2017-04-10 15:39:43 RE: herencia y key
Previous Message Lazaro Garcia 2017-04-10 15:05:08 resultado inesperado con pgbench