practica bd
TRANSCRIPT
-
8/17/2019 Practica Bd
1/10
CREACION DE TABLAS
create table Producto(IdProducto char(10),Nombre varchar2(30),Marca varchar2(30),Precio number,Stock number,IdCategoria char(10))
create table Categoria(Id char(10),Nombre varchar2(30))
create table !etalle"enta(Cantidad number,Precio number,Id"enta char(10),IdProducto char(10))
create table "enta(Id"enta char(10),
#echa !$%&,!etalle varchar2(30),IdCliente char(10))
create table Cliente(IdCliente char(10),Nombre varchar2(30),!ireccion varchar2(30),
%ele'ono char(1))
alter table Productoadd (contraint Producto*IdProducto*P+
rimar- ke- (IdProducto))
alter table Categoriaadd (contraint Categoria*Id*P+ rimar- ke- (Id))
alter table "entaadd (contraint "enta*Id"enta*P+ rimar- ke- (Id"enta))
alter table Clienteadd (contraint Cliente*IdCliente*P+
rimar- ke- (IdCliente))
alter table Productoadd (contraint Producto*IdCategoria*#+ 'oreign ke- (IdCategoria)re'erence Categoria(Id))
alter table !etalle"entaadd (contraint !etalle"enta*IdProducto*#+ 'oreign ke- (IdProducto)
-
8/17/2019 Practica Bd
2/10
re'erence Producto(IdProducto))
alter table !etalle"entaadd (contraint !etalle"enta*Id"enta*#+ 'oreign ke- (Id"enta)re'erence "enta(Id"enta))
alter table "entaadd (contraint "enta*IdCliente*#+
'oreign ke- (IdCliente)re'erence Cliente(IdCliente))
inert into Producto(IdProducto,Nombre,Marca,Precio,Stock,IdCategoria)value (.P01., .cu.,.lenovo.,.1000., .10.,.C01.)
inert into Producto(IdProducto,Nombre,Marca,Precio,Stock,IdCategoria)value (.P02.,.lato.,.on-.,.200.,.1.,.C02.)
inert into Producto(IdProducto,Nombre,Marca,Precio,Stock,IdCategoria)value (.P03.,.can/et.,.eon.,.00.,.10.,.C03.)
inert into Producto(IdProducto,Nombre,Marca,Precio,Stock,IdCategoria)value (.P0.,.laer1020.,.h.,.00.,.20.,.C0.)
inert into Producto(IdProducto,Nombre,Marca,Precio,Stock,IdCategoria)value (.P0.,.Smini.,.Samung.,.300.,.10.,.C0.)
inert into Categoria(Id,Nombre) value (.C01.,.comutadora.)
inert into Categoria(Id,Nombre) value (.C02.,.lato.)
inert into Categoria(Id,Nombre) value (.C03.,.canner.)
inert into Categoria(Id,Nombre) value (.C0.,.imreora.)
inert into Categoria(Id,Nombre) value (.C0.,.celulare.)
inert into Cliente(IdCliente,Nombre,!ireccion,%ele'ono)value (.CI01.,.4avier*cacere.,.calacoto.,.25511.)
inert into Cliente(IdCliente,Nombre,!ireccion,%ele'ono)value (.CI02.,./oe*a-e.,.eri'erica.,.2165.)
inert into Cliente(IdCliente,Nombre,!ireccion,%ele'ono)value (.CI03.,./oe*valer.,.calacoto.,.215.)
inert into Cliente(IdCliente,Nombre,!ireccion,%ele'ono)value (.CI0.,.edgar*loe7.,.mira8ore.,.222525.)
inert into Cliente(IdCliente,Nombre,!ireccion,%ele'ono)value (.CI0.,.guido*ere7.,.$chachicala.,.55.)
-
8/17/2019 Practica Bd
3/10
inert into "enta(Id"enta,#echa,!etalle,IdCliente)value (."01.,.019019201.,.cu*negro.,.CI01.)
inert into "enta(Id"enta,#echa,!etalle,IdCliente)value (."02., .029019201.,.lato*lomo.,.CI02.)
inert into "enta(Id"enta,#echa,!etalle,IdCliente)value (."03.,.039019201.,.canner*blanco.,.CI03.)
inert into "enta(Id"enta,#echa,!etalle,IdCliente)value (."0., .09019201.,.Imreora*tabloide.,.CI0.)
inert into "enta(Id"enta,#echa,!etalle,IdCliente)value (."0., .09019201.,.nokia*negro.,.CI0.)
inert into !etalle"enta(Cantidad,Precio,Idventa,IdProducto)value (.1.,.1000.,."01.,.P01.)
inert into !etalle"enta(Cantidad,Precio,Idventa,IdProducto)
value (.1.,.200.,."02.,.P02.)
inert into !etalle"enta(Cantidad,Precio,Idventa,IdProducto)value (.1.,.00.,."03.,.P03.)
inert into !etalle"enta(Cantidad,Precio,Idventa,IdProducto)value (.1.,.00.,."0.,.P0.)
inert into !etalle"enta(Cantidad,Precio,Idventa,IdProducto)value (.1.,.300.,."0.,.P0.)
CONSULTAS A LA BASE DE DATOS (ventas)
elect P:IdProducto,P:Nombre,P:Marca,P:Precio,P:Stock,P:IdCategoria,C:Id,C:Nombre'rom Producto P,Categoria C;here P:IdCategoria
-
8/17/2019 Practica Bd
4/10
elect !:cantidad,!:Precio,!:Id"enta,!:IdProducto,":Id"enta,":#echa,":IdCliente'rom !etalle"enta !,"enta ";here !:Id"enta
-
8/17/2019 Practica Bd
5/10
le't /oin !etalle"enta !on P:IdProducto
elect !:cantidad,!:Precio,!:Id"enta,!:IdProducto,":Id"enta,":#echa,":IdCliente'rom !etalle"enta !le't /oin "enta "on !:Id"enta
-
8/17/2019 Practica Bd
6/10
electP:IdProducto,P:Nombre,P:Marca,P:Precio,P:Stock,P:IdCategoria,!:Cantidad,!:Precio,!:Id"enta, !:IdProducto'rom Producto Pright /oin !etalle"enta !on P:IdProducto
elect !:cantidad,!:Precio,!:Id"enta,!:IdProducto,":Id"enta,":#echa,":IdCliente'rom !etalle"enta !right /oin "enta "on !:Id"enta
-
8/17/2019 Practica Bd
7/10
electP:IdProducto,P:Nombre,P:Marca,P:Precio,P:Stock,P:IdCategoria,!:Cantidad,!:Precio,!:Id"enta, !:IdProducto'rom Producto P'ull /oin !etalle"enta !on P:IdProducto
elect !:cantidad,!:Precio,!:Id"enta,!:IdProducto,":Id"enta,":#echa,":IdCliente'rom !etalle"enta !'ull /oin "enta "on !:Id"enta
-
8/17/2019 Practica Bd
8/10
'rom Productounionelect Id,Nombre'rom Categoria
elect Precio,IdProducto'rom Productounionelect Precio,IdProducto'rom !etalle"enta
elect Id"enta'rom !etalle"entaunion
elect Id"enta'rom "enta
elect IdCliente'rom "entaunionelect IdCliente'rom Cliente
elect IdProducto,Nombre'rom Productounion allelect Id,Nombre'rom Categoria
-
8/17/2019 Practica Bd
9/10
elect Precio,IdProducto'rom Productounion allelect Precio,IdProducto'rom !etalle"enta
elect Id"enta'rom !etalle"entaunion allelect Id"enta'rom "enta
elect IdCliente'rom "entaunion allelect IdCliente'rom Cliente
elect Idcategoria'rom Productointerectelect Id'rom Categoria
elect Precio,IdProducto
'rom Productointerectelect Precio,IdProducto'rom !etalle"enta
-
8/17/2019 Practica Bd
10/10
elect Id"enta'rom !etalle"entainterectelect Id"enta'rom "enta
elect IdCliente'rom "entainterectelect IdCliente'rom Cliente
elect IdProducto,Nombre'rom Producto
minuelect Id,Nombre'rom Categoria
elect Precio,IdProducto'rom Productominuelect Precio,IdProducto'rom !etalle"enta
elect Id"enta'rom !etalle"entaminuelect Id"enta'rom "enta
elect IdCliente'rom "entaminu
elect IdCliente'rom Cliente