The document creates a database called "yuly" and specifies its size, growth, and location. It then creates 11 tables to store data for suppliers, articles, inventory, sales, sale details, employees, employee details, clients, and client details. Primary keys are set for each table and some basic columns are defined. Select statements are included to view the data in each new table.
1. use master
go
create database yuly
on primary(
name= 'yuly_data',
filename= 'C:datayuly_data.mdf',
size=4mb,
maxsize=10mb,
filegrowth=1mb
)
log on (
name= 'yuly_log',
filename= 'C:datayuly_data.ldf',
size=2mb,
maxsize=10mb,
filegrowth=1mb
)
go
use yuly
go
create table Proveedores(
Id_Proveedor int primary key not null,
Nom_Proveedor char(20) not null,
Fabricante char(20) not null,
Dirección char(30) not null,
Zona char(20) not null
)
select* from Proveedores
create table Articulos(
Id_Articulo int primary key not null,
Nom_Art char(20) not null,
Tipo char(20) not null,
Fabricante char(20) not null,
Id_Proveedor int not null,
Contenido smallint not null,
Precio Money not null,
)
select* from Articulos
create table Inventario(
Id_Articulo int primary key not null,
No_Almacen int not null,
Nom_Art char(20) not null,
Id_Proveedor int not null,
Precio Money not null,
Existencia int not null
)
select* from Inventario
create table Ventas(
Id_Factura int primary key not null,
2. Id_Cliente int not null,
Id_Articulo int not null,
Id_Empleado int not null,
Fecha date not null
)
select* from Ventas
create table Detalle_Venta(
Id_Factura int primary key not null,
Nom_Art char(20) not null,
Tipo char(20) not null,
Importe_Uni smallint not null,
Piezas int not null,
Total int not null
)
select * from Detalle_Venta
create table Empleados(
Id_Empleado int primary key not null,
Nombre char(20) not null,
Apellidos char(30) null
)
select * from Empleados
create table Detalle_Emp(
Id_Empleado int primary key not null,
Edad smallint null,
Puesto char(30) not null,
Antiguedad smallint not null,
Dirección char(30) not null,
Tel smallint not null,
CP char(10) null
)
select * from Detalle_Emp
create table Clientes(
Id_Cliente int primary key not null,
Nom_Cliente char(20) not null,
Apellidos char(30) null
)
select * from Clientes
create table Detalle_Cliente(
Id_Cliente int primary key not null,
Dirección char(30) not null,
Tel int not null,
Correo char(30) null,
CP char(20) null
)
select * from Detalle_Cliente