Sunteți pe pagina 1din 2

/*Estudiante:

George Castillo
*/

Create Database EmpresaDeVentasDeAutos


On primary
(
Name = 'EmpresaDeVentasDeAutos_Data',
Filename = 'C:\Users\George Castillo\Documents\SQL Server Management
Studio\EmpresaDeVentasDeAutos.MDF',
Size = 10MB,
MAXSIZE = 25,
FILEGROWTH = 2MB
)
Log On
(
Name = 'EmpresaDeVentasDeAutos_Log',
Filename = 'C:\Users\George Castillo\Documents\SQL Server Management
Studio\EmpresaDeVentasDeAutos.LDF',
Size =4MB,
MAXSIZE = 10,
FILEGROWTH = 20%
)
GO
GO

USE EmpresaDeVentasDeAutos
GO

Create Table Cliente


(
NIF nchar(10) not null,
Nombre char(15),
Direccion varchar(15),
Ciudad char(10),
Telefono varchar(10),
Constraint PK_Cliente_NIF Primary key (NIF),
)
GO

Create Table Autos


(
Matricula varchar(8) not null,
Marca varchar(15),
Modelo varchar(10),
Color char(10),
NIF nchar(10) not null,
constraint Pk_Autos_Matricula Primary key (Matricula),
Constraint Pk_Cliente_Matricula Foreign key (NIF)References Cliente (NIF),
)
GO

Create Table Revision


(

CambioDeFiltro date not null,


CambioDeAceite date,
CambioDeFreno date,
Otros date Null,
Matricula varchar(8) not null,
constraint Pk_Revision_CambioDeFiltro primary key (CambioDeFiltro),
constraint pk_Autos_CambioDeFilro foreign key (Matricula) references Autos
(Matricula),
)
GO

// Agregando Datos a lasTablas 2

USE VentasDeAutos_2
GO
INSERT INTO Cliente (NIF, Nombre, Direccion, Ciudad, Telefono) VALUES ('9-753-3569',
'Fabian Castrellon', 'Santa Rita', 'Sona', '6456-2967')
INSERT INTO Cliente (NIF, Nombre, Direccion, Ciudad, Telefono) VALUES ('9-356-743',
'Irving Martinez', 'Marañon', 'Sona', '6369-886')
INSERT INTO Cliente (NIF, Nombre, Direccion, Ciudad, Telefono) VALUES ('8-967-4634',
'Jonathan Castillo', 'Los Balsas', 'Santiago', '6580-6634')
GO
INSERT INTO Autos (Matricula, Marca, Modelo, Color, NIF) VALUES ('BD546', 'For',
'Mustang', 'Rojo', '9-753-3569')
INSERT INTO Autos (Matricula, Marca, Modelo, Color, NIF) VALUES ('TUN4367', 'Dodge',
'Challeger', 'Negro', '9-356-743')
INSERT INTO Autos (Matricula, Marca, Modelo, Color, NIF) VALUES ('BC894',
'Acura', 'Lxrs', 'Azul', '8-967-4634')
GO
INSERT INTO Revision (CambioDeFiltro, CambioDeAceite, CambioDeFreno, Otros,
Matricula) VALUES ('2019/08/05', '2019/12/18', '2019/04/09', '2019/02/15', 'BD546')
INSERT INTO Revision (CambioDeFiltro, CambioDeAceite, CambioDeFreno, Otros,
Matricula) VALUES ('2018/10/20', '2018/04/06', '2018/09/26', '2018/01/20',
'TUN4367')
INSERT INTO Revision (CambioDeFiltro, CambioDeAceite, CambioDeFreno, Otros,
Matricula) VALUES ('2016/02/11', '2016/03/30', '2016/01/18', '2016/05/04', 'BC894')
GO

S-ar putea să vă placă și