You are on page 1of 3

-- BASE DE DATOS DE UN HOSPEDAJxRossell

create database hospedaje;

use hospedaje;

-- TABLA PERSONAS....

create table persona(

idPersona int(10) not null auto_increment,

nombrePersona varchar(50) not null,

nacionalidadPersonas varchar(70) not null,

primary key (idPersona)

);

-- TABLA DE CLIENTES...

create table cliente(

rucCliente bigint not null auto_increment,

direccionCliente varchar(35),

primary key (rucCliente)

);

-- TABLAD DE HUESPEDES....

create table huesped(

edadHuesped int(10) not null auto_increment,

primary key (edadHuesped)

);

-- _______________________________________________________________________________

-- CREATE TABLE HUESPED HAS RESERVAS HAS HABITACION...

create table huesped_has_reservas_has_habitacion(

huesped_has_reservas_has_habitacion_edadHuesped int(10) not null auto_increment,

huesped_has_reservas_has_habitacion_fechaLlegada date null,

primary key (huesped_has_reservas_has_habitacion_edadHuesped),

foreign key (huesped_has_reservas_has_habitacion_edadHuesped)


references huesped (edadHuesped),

foreign key (huesped_has_reservas_has_habitacion_fechaLlegada)

references reservas_has_habitacion(fechaLlegada)

);

-- ________________________________________________________________________________

--
-----------------------------------------------------------------------------------
---------------

-- TABLA DE RESERVAS.....

create table reservas(

idReservas bigint not null,

fechaRerervas date null,

reservas_rucCliente bigint not null auto_increment,

primary key (idReservas),

foreign key (reservas_rucCliente)

references cliente(rucCliente)

);

-- ___________________________________________________________________

-- TABLA DE RESERVAS Y HABITACIONES, N:M...

create table reservas_has_habitacion(

fechaLlegada date null,

fechaSalida date null,

reservas_has_habitacion_idReservas bigint not null,

reservas_has_habitacion_idHabitacion bigint not null auto_increment,

primary key (fechaLlegada),

foreign key (reservas_has_habitacion_idReservas)

references reservas (idReservas),

foreign key (reservas_has_habitacion_idHabitacion)

references habitacion (idHabitacion)

);
-- _____________________________________________________________________

-- TABLA DE HABITACIONEES.....

create table habitacion(

idHabitacion bigint not null auto_increment,

nombreHabitacion varchar(50) not null,

primary key (idHabitacion)

);

--
-----------------------------------------------------------------------------------
--------------

-- TABLA DE SERVICIOS..

create table servicios(

idServicios int not null,

costoServivios varchar(1509),

primary key (idServicios),

servicios_idFactura bigint not null auto_increment,

servicios_fechaLlegada date null,

foreign key (servicios_idFactura)

references factura(idFactura),

foreign key (servicios_fechaLlegada)

references reservas_has_habitacion(fechaLlegada)

);

-- TABLA DE FACTURAS...

create table factura(

idFactura bigint not null auto_increment,

fechaFactura date not null,

primary key (idFactura)

);

You might also like