Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create database Libreria
- go
- use Libreria
- go
- create table Provincias(
- ID_Provincia int not null identity(1,1) primary key,
- Nombre varchar(30) not null unique
- )
- go
- create table Paises(
- ID_Pais int not null identity(1,1) primary key,
- Nombre varchar(30) not null unique
- )
- go
- create table Direcciones(
- ID_Direccion int not null identity(1,1) primary key,
- ID_Pais int not null foreign key references Paises(ID_Pais),
- ID_Provincia int not null foreign key references Provincias(ID_Provincia),
- Calle varchar(30) not null,
- Altura smallint not null
- )
- go
- create table Clientes(
- ID_Cliente int not null identity(1,1) primary key,
- Nombre varchar(30) not null,
- Apellido varchar(30) not null,
- Correo_Electronico varchar(30) not null,
- Fecha_Nacimiento date not null,
- ID_Direccion int not null foreign key references Direcciones(ID_Direccion)
- )
- go
- create table Categorias(
- ID_Categoria int not null identity(1,1) primary key,
- Nombre_Categoria varchar(30) not null,
- )
- go
- create table Autores(
- ID_Autor int not null identity(1,1) primary key,
- ID_Pais int null foreign key references Paises(ID_Pais),
- Nombre_Autor varchar(30) not null
- )
- go
- create table Libros(
- ID_Libro int not null identity(1,1) primary key,
- Titulo varchar(30) not null,
- Año_Publicacion smallint not null,
- ID_Categoria int not null foreign key references Categorias (ID_Categoria),
- ID_Autor int null foreign key references Autores (ID_Autor),
- )
- go
- create table Libros_X_Clientes(
- ID_Compra int not null identity(1,1) primary key,
- ID_Cliente int not null foreign key references Clientes(ID_Cliente),
- ID_Libro int not null foreign key references Libros(ID_Libro),
- Fecha_Compra date not null,
- Puntaje tinyint null check (puntaje>=0 AND puntaje <=10)
- )
Advertisement
Add Comment
Please, Sign In to add comment