Created
September 30, 2023 15:47
-
-
Save SebastianCastilloDev/55d95337ee894b4dfdc84abb20cdc696 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create database ParkingSystemsSA | |
go | |
use ParkingSystemsSA | |
go | |
create table Cliente( | |
idCliente int primary key identity, | |
rut varchar(9) unique null, | |
nombre varchar(50), | |
correo varchar(50), | |
telefono varchar(9), | |
direccion varchar(50), | |
fechaRegistro datetime default getdate() | |
) | |
go | |
create table Vehiculo( | |
idVehiculo int primary key identity, | |
patente varchar(50), | |
marca varchar(50), | |
modelo varchar(50), | |
color varchar(50), | |
fechaRegistro datetime default getdate() | |
) | |
go | |
create table Estacionamiento( | |
idEstacionamiento int primary key not null, | |
x int not null, | |
y int not null, | |
disponible bit not null default 1, | |
) | |
go | |
create table Pago ( | |
idPago int primary key identity, | |
monto int, | |
fechaRegistro datetime default getdate() | |
) | |
go | |
create table Registro( | |
idRegistro int primary key identity, | |
idEstacionamiento int references Estacionamiento(idEstacionamiento), | |
entrada datetime, | |
salida datetime, | |
fechaRegistro datetime default getdate() | |
) | |
go | |
--Poblando los datos de la tabla estacionamiento | |
declare @x as int | |
declare @y as int | |
declare @IdEstacionamiento as int | |
set @IdEstacionamiento = 0 | |
set @x = 0 | |
while (@x < 10) | |
begin | |
set @y = 0 | |
while (@y < 10) | |
begin | |
INSERT INTO Estacionamiento(idEstacionamiento,x,y,disponible) VALUES (@idEstacionamiento,@x,@y,1) | |
set @IdEstacionamiento = @IdEstacionamiento + 1 | |
set @y = @y + 1 | |
end | |
set @x = @x+1 | |
end | |
go| | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment