ENTIDAD DE RELACION Y DIAGRAMA DE SQL DE UN ALQUILER DE PELICULAS

Ver el tema anterior Ver el tema siguiente Ir abajo

ENTIDAD DE RELACION Y DIAGRAMA DE SQL DE UN ALQUILER DE PELICULAS

Mensaje  Nando F.r.v. el Jue Mar 24, 2011 11:12 pm







create database alquiler1
use alquiler1

create table peliculas
(
pelid numeric(18,0)not null,
pelnom nvarchar (50) not null ,
palcan nvarchar (20) not null,
gencod numeric (18,0) not null,

constraint pk_pelid primary key (pelid)
);

create table cliente
(
clicod numeric (18,0)not null ,
clinom nvarchar (25) not null,
cliape nvarchar (25) not null,
clidir nvarchar (30) not null,
clitel nvarchar (15) not null,

constraint PK_clicod primary key (clicod));


create table vendedor
(
vencod numeric (18,0) not null ,
vennom nvarchar (25) not null,
venape nvarchar (25) not null,
ventel nvarchar (15) not null,
constraint PK_vencod primary key (vencod));


create table generos
(
gencod numeric (18,0) not null,
gennom nvarchar (30) not null,
constraint PK_gencod primary key (gencod));



create table valor_alquiler
(
numpel numeric (18,0)not null ,
vlrpel numeric (25,0)not null,
constraint PK_numpel primary key (numpel));


create table factura_detalle
(
pelidi numeric (18,0)not null,
pelnom nvarchar (20) not null,
gencod numeric (18,0) not null,
gennom nvarchar (20) not null,
numpel numeric (18,0) not null,
fecha_ent datetime not null,
fecha_sal datetime not null,
codest numeric (18,0)not null,
vencod numeric (18,0)not null,
clicod numeric(18,0)not null,
constraint PK_pelidi primary key (pelidi));


create table factura_cabecera
(
clicod numeric (18,0) not null,
clinom nvarchar (15) not null,
vencod numeric (18,0)not null,
vennom nvarchar (15)not null,
fecha datetime,
hora datetime,
total numeric (18,0)not null,
iva numeric (18,0)not null,
factdetpel numeric (18,0)not null,
constraint PK_clicod primary key (clicod));

create table estado
(
codest numeric(18,0)not null,
nomest nvarchar (15) not null,
limitdias nvarchar(20)not null,

constraint PK_codest primary key (codest));


alter table peliculas add constraint fk_pelid foreign key(pelid)references factura_detalle (pelid);
alter table cliente add constraint fk_clicod foreign key(clicod)references factura_cabecera (clicod);
alter table vendedor add constraint fk_vencod foreign key(vencod)references factura_detalle (vencod);
alter table generos add constraint fk_gencod foreign key(gencod)references peliculas (gencod);
alter table valor_alquiler add constraint fk_numpel foreign key(numpel) references factura_detalle (numpel);
alter table factura_detalle add constraint fk_pelid foreign key(pelid)references generos (pelid);
alter table factura_detalle add constraint fk_clicod foreign key (clicod) references factura_cabecera (clicod);
alter table factura_detalle add constraint fk_vencod foreign key (vencod) references vendedor (vencod);
alter table factura_detalle add constraint fk_clicod foreign key (clicod) references cliente (clicod);
alter table estado add constraint fk_codest foreign key (codest) references factura_detalle (codest);


insert into generos values
(01,'tsunami')
(02,'terremoto')
(03,'el ninja ciego'),
(04,'la piraña mueca'),
(05,'la mirada del ciego'),
(06,'la patada del cojo'),
(07,'el visco'),
(08,'el chapulin'),
(09,'el chavo'),
(10,'saw')
;


insert into cliente values
(1,'andres','lopez','cra 45#1-12',5536874),
(2,'camilo','diaz','cra 87#1-54',2356554),
(3,'julian','cuatin','calle 3#5-44',6541478),
(4,'fernando','aguirre','calle3#1-85',5534587),
(5,'maria','fernandez','ave3norte#3n-54',5587478),
(6,'lucas','ramirez','calle5#5-74',5536874),
(7,'mateo','loaiza','cra85#85-12',5547871),
(8,'carlos','leal','calle6#45-96',6398578),
(9,'carolina','florez','ave1#1-96',6835478),
(10,'vanessa','cardona','calle3#5-36',5688887),
;

insert into peliculas values
(01,'saw7',5,100),
(02,'saw6',6,100),
(03,'saw5',5,100),
(04,'saw4',9,100),
(05,'saw3',9,100),
(06,'saw2',4,100),
(07,'saw1',4,100),
(08,'el origen',2,100),
(09,'el padrino',1,100),
(10,'tiburon',1,100)
;

insert into vendedor values
(101,'steven','pasaje'5536987),
(102,'santiago','perez'5537787),
(103,'sebastian','potes'5538987),
(104,'sandra','puerta'5578977),
(105,'sara','pportilla'5533987),
(106,'frank','muñoz'5512487),
(107,'fernando','manrique'5836987),
(108,'fernando','marquez'5963987),
(109,'francy','murillo'5565987),
(110,'camilo','libardo'5536987),
(101,'steven','pasaje'5536987)
;

insert into valor_alquiler values
(01,10000),
(02,10800),
(03,15000),
(04,11100),
(05,20000),
(06,25000),
(07,30000),
(08,35000),
(09,40000),
(10,45000)
;


Nando F.r.v.

Mensajes : 5
Fecha de inscripción : 09/02/2011

Ver perfil de usuario

Volver arriba Ir abajo

Ver el tema anterior Ver el tema siguiente Volver arriba

- Temas similares

 
Permisos de este foro:
No puedes responder a temas en este foro.