Ejemplo script base de datos

Páginas: 1 (250 palabras) Publicado: 7 de diciembre de 2011
create database Biblioteca

go

use Biblioteca

go

create table PERSONAS(

id_persona varchar(30) not null primary key,

nombre varchar(50) not null,

apellido1 varchar(50) notnull,

apellido2 varchar(50) null,

correo varchar(50) null,

tel_hab varchar(50) null,

tel_cel varchar(50) null,

direccion varchar(50)null,

observacion varchar(50) null,

)

gocreate table USUARIOS_PERFIL(

id_perfil smallint not null primary key,

descripcion varchar(15) not null,

check (id_perfil >= 0 and id_perfil < 32766)

)

go

create tableUSUARIOS(

username varchar(30) not null primary key,

password varchar(30) not null,

id_persona varchar(30) not null,

id_perfil smallint not null,

foreign key(id_persona) referencesPERSONAS,

foreign key(id_perfil) references USUARIOS_PERFIL

)

go

create table LIBROS_CATEGORIA(

id_categoria smallint not null primary key,

descripcion varchar(70) not null,check (id_categoria >= 0 and id_categoria < 32766)

)

go

create table LIBROS_INVENTARIO(

id_libro int not null primary key,

nombre varchar(300) not null,

autor varchar(300) not null,cantidad tinyint not null,

disponibilidad tinyint not null,

id_categoria smallint not null,

foreign key(id_categoria) references LIBROS_CATEGORIA,

check (disponibilidad >= 0 anddisponibilidad < 255)

)

go

create table PRESTAMO(

id_prestamo int not null primary key,

estado varchar(10) not null,

id_persona varchar(30) not null,

id_libro int not null,fecha_entrega date not null,

responsable_entrega varchar(30) not null,

fecha_recibo date not null,

responsable_recibo varchar(30) not null,

multa int not null,

foreignkey(id_persona) references PERSONAS,

foreign key(id_libro) references LIBROS_INVENTARIO,

check (id_prestamo > 0)

)

go

insert into USUARIOS_PERFIL values (1,'Administrador')

insert into...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Script De Auditoria De Base De Datos
  • base de datos ejemplos
  • Ejemplos De Sistemas De Bases De Datos
  • Casos de base de datos (ejemplos)
  • Ejemplo sencillo de una base de datos
  • Ejemplo de base de datos
  • base de datos ejemplo
  • Base De Datos Ejemplo

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS