CREATE TABLE vendedor ( ven_id int8 NOT NULL, ven_nom

Anuncio
CREATE TABLE vendedor
(
ven_id int8 NOT NULL,
ven_nom varchar(20),
ven_ape varchar(20),
ven_sex varchar(1),
ven_tel varchar(20),
ven_dir varchar(20),
ven_suebas float4 NOT NULL DEFAULT 0,
ven_comven float4 NOT NULL DEFAULT 1.5,
check (ven_sex='f' or ven_sex= 'm'),
PRIMARY KEY (ven_id)
);
CREATE TABLE cliente
(
cli_cc int8 NOT NULL,
cli_nom varchar(30),
cli_ape varchar(30),
cli_sex varchar(1),
cli_edad int2,
cli_dir varchar(50),
cli_tel varchar(30),
PRIMARY KEY (cli_cc)
);
CREATE TABLE articulo
(
art_id int8 NOT NULL,
art_nom varchar(20),
art_valuni float4 NOT NULL DEFAULT 0,
art_canexi int2 NOT NULL DEFAULT 0,
art_minexi int2 NOT NULL DEFAULT 0,
art_maxexi int2 NOT NULL DEFAULT 0,
PRIMARY KEY (art_id)
);
CREATE TABLE forpag
(
for_id int2 NOT NULL,
for_nom varchar(20) NOT NULL,
PRIMARY KEY (for_id)
);
CREATE TABLE factura
(
fac_num int8 NOT NULL,
fac_clicc int8 NOT NULL,
fac_venid int8 NOT NULL,
fac_fecha date,
fac_hora time,
fac_subtotal float4 NOT NULL DEFAULT 0,
fac_iva float4 NOT NULL DEFAULT 16,
fac_des float4 NOT NULL DEFAULT 0,
fac_forid int2 NOT NULL DEFAULT 1,
PRIMARY KEY (fac_num),
FOREIGN KEY (fac_venid) REFERENCES vendedor (ven_id),
FOREIGN KEY (fac_clicc) REFERENCES cliente (cli_cc),
FOREIGN KEY (fac_forid) REFERENCES forpag (for_id)
);
CREATE TABLE artxfac
(
axf_facnum int8 NOT NULL,
axf_artid int8 NOT NULL,
axf_canven int2 NOT NULL DEFAULT 1,
PRIMARY KEY (axf_facnum, axf_artid),
FOREIGN KEY (axf_artid) REFERENCES articulo (art_id),
FOREIGN KEY (axf_facnum) REFERENCES factura (fac_num)
);
Descargar