( ( ) not null, ( )) ( ( ) not null, ( ), ( )) ( ( ) not null, ( ), ( ), ( ), ( ))

create database biblioteca use biblioteca create table especialidad( cod_especialidad varchar(8) primary key not null, n

Views 233 Downloads 1 File size 196KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

create database biblioteca use biblioteca create table especialidad( cod_especialidad varchar(8) primary key not null, nom_especialidad varchar(25)) create table autor( cod_autor varchar(8) primary key not null, nom_autor varchar(30), nacionalidad varchar(20)) create table editorial( cod_editorial varchar(8) primary key not null, nom_editoial varchar(13), tel_editorial varchar(9), correo_editorial varchar(30), representante_editorial varchar(10)) --alter table editorial --add primary key nonclustered --(cod_editorial) /* si no le hubiera puesto PK a cod_editorial */ create table alumno( cod_alumno varchar(8) primary key not null, nom_alumno varchar(40), dir_alumno varchar(40), tel_alumno varchar(9), correo_alumno varchar(40), carrera_alumno varchar(2)) create table prestamo( num_prestamo int not null primary key, fech_prestamo varchar(8), hora_prestamo varchar(6), fecha_devolucion varchar(8), cod_alumno varchar(8), id_libro int) alter table add foreign alter table add foreign

prestamo key (cod_alumno) references alumno prestamo key (id_libro) references libro

create table libro( id_libro int primary key not null, titulo_libro varchar(10), num_paginas int, año_publicac int, cod_autor varchar(8), cod_editorial varchar(8), cod_especialidad varchar(8) ) alter table libro add foreign key (cod_autor) references autor alter table libro

add foreign key (cod_editorial) references editorial alter table libro add foreign key (cod_especialidad) references especialidad

-- el fin supremo de una bd es almacena datos insert into alumno values('20172100','Giannina Bernal Navarrete','Mz. no tee wa decir','965715474','[email protected]','is') insert into alumno values('20172101','Bryghite Bernal Navarrete','Mz. no te wa decir.1','965715475','[email protected]','is') insert into alumno values('20172102','Enrique Bernal Navarrete','Mz. no te wa decir.2','965715476','[email protected]','is') insert into alumno values('20172103','Kolbher Bernal Navarrete','Mz. no te wa decir.3','965715477','[email protected]','is') insert into alumno values('20172104','Nina Bernal Navarrete','Mz. no te wa decir.4','965715478','[email protected]','is') select * from alumno

atash y detash