domingo, 17 de junio de 2018

Fecha Inicial : .17/06/2018
Fecha Final :  .17/06/2018
Hora Inicio: .12:24 PM
Hora Final: .1:31 PM
Horas invertidas(Minutos): 67
Colaboradores: Óscar  Cortés
Tipo de labor: Individual



Actividad:
Modificación del script de creación las tablas 


Consultar por el diagrama al profesor


Imágenes:







Apéndice:


  • Versión del código: 1.1
  •  .
/*
use master
create database sheDoesntLoveYou
go
*/

use sheDoesntLoveYou
go


CREATE TABLE TipoCliente(
    ID INT PRIMARY KEY identity(1,1),
    Descripcion varchar(30) NOT NULL,
    Visible CHAR NOT NULL default 'y', CHECK (Visible = 'y' OR Visible = 'n')
)

CREATE TABLE Cliente(
    ID INT PRIMARY KEY identity(1,1),
    Nombre varchar(30) NOT NULL,
    DocID INT NOT NULL,
    FK_Tipo_Cliente INT NOT NULL FOREIGN KEY REFERENCES TipoCliente(ID),

    Visible CHAR NOT NULL default 'y', CHECK (Visible = 'y' OR Visible = 'n')
)

CREATE TABLE Emisor(
     ID INT PRIMARY KEY identity(1,1),
     DocID INT NOT NULL,
     Nombre varchar(30) NOT NULL,
     QAcciones INT NOT NULL,
     PrecioInicial MONEY NOT NULL,
     Variacion INT NOT NULL,
     Comision INT NOT NULL,
     Visible CHAR NOT NULL default 'y', CHECK (Visible = 'y' OR Visible = 'n')
)


CREATE TABLE ClienteDeEmpresa(
ID INT PRIMARY KEY identity(1,1),
FK_Emisor int not null foreign key references Emisor(ID),
FK_Cliente int not null foreign key references Cliente(ID)
)

CREATE TABLE ClienteXEmisor(
ID INT PRIMARY KEY identity(1,1),
FK_Emisor int not null foreign key references Emisor(ID),
FK_Cliente int not null foreign key references Cliente(ID),

QAcciones int not null
)





create table MovimientoAcciones(
ID INT PRIMARY KEY identity(1,1),
FK_ClienteEmisor int not null foreign key references ClienteEmisor(ID),
Cantidad int not null default 0,
Precio money not null default 0
)

CREATE TABLE Accion(
    ID INT PRIMARY KEY identity(1,1),
FK_Emisor INT not null foreign key references Emisor(ID),
FK_Movmiento int not null foreign key references MovimientoAcciones(ID),
    Codigo INT NOT NULL,
    PrecioActual MONEY NOT NULL,

    Visible CHAR NOT NULL default 'y', CHECK (Visible = 'y' OR Visible = 'n')
)


CREATE TABLE Agente(
     ID INT PRIMARY KEY identity(1,1),
     Nombre varchar(30) NOT NULL,
     Saldo INT NOT NULL,
     Visible CHAR NOT NULL default 'y', CHECK (Visible = 'y' OR Visible = 'n')
)

CREATE TABLE TipoOperacion(
    ID INT PRIMARY KEY identity(1,1),
    Descripcion varchar(30) NOT NULL,
    Visible CHAR NOT NULL default 'y', CHECK (Visible = 'y' OR Visible = 'n')
)


CREATE TABLE Operacion(
     ID INT PRIMARY KEY identity(1,1),
FK_TipoOperacion INT NOT NULL FOREIGN KEY REFERENCES TipoOperacion(ID),
     FK_Agente INT NOT NULL FOREIGN KEY REFERENCES Agente(ID),
     FK_ClienteCompra INT NOT NULL FOREIGN KEY REFERENCES Cliente(ID),
     FK_ClienteVenta INT NOT NULL FOREIGN KEY REFERENCES Cliente(ID),
     FK_Movimiento int not null foreign key references MovimientoAcciones(ID),

Fecha DATE NOT NULL,
     QAcciones INT NOT NULL,
Total int not null,
Comision int not null,

     Visible CHAR NOT NULL default 'y', CHECK (Visible = 'y' OR Visible = 'n')
)

-- Todo esta bien arriba

CREATE TABLE TipoMovimiento(
    ID INT PRIMARY KEY identity(1,1),
    Descripcion varchar(30) NOT NULL,
    Visible CHAR NOT NULL default 'y', CHECK (Visible = 'y' OR Visible = 'n')
)







CREATE TABLE MovimientoComision(
   ID INT PRIMARY KEY identity(1,1),
   FK_Agente INT NOT NULL FOREIGN KEY REFERENCES Agente(ID),
   FK_Tipo_Movimiento INT NOT NULL FOREIGN KEY REFERENCES TipoMovimiento(ID),
   FK_Operacion INT NOT NULL FOREIGN KEY REFERENCES Operacion(ID),

   Fecha DATE NOT NULL,
   Monto MONEY NOT NULL,
   
   Visible CHAR NOT NULL default 'y', CHECK (Visible = 'y' OR Visible = 'n')
)





CREATE TABLE EventoMantenimiento (
ID INT identity(1,1) primary key,
Tabla NVARCHAR(50) NOT NULL,
Antes XML NOT NULL,
Despues XML NOT NULL,
Fecha DATE NOT NULL default (getDate())
)
  • Mejoras: Se logran terminar las conexiones entre las tablas.



No hay comentarios.:

Publicar un comentario