Base de datos Algebra relacional
Base de Datos I
Unidad II: Algebra Relacional
Tema:
Operaciones Conjuntistas
Operaciones Relacionales
A: Clientes
Primary key: Id_Cliente
Nombre, Dir, Tel_Conv, Tel_Cel
B:Facturas
primary Key: NFact
Fecha_Fact, Id_Cliente(fk), SubtotalF
OPERACIONES CONJUNTISTAS
1) Union
AUB
Select Nombre, Dir, Tel_Conv, Tel_Cel, Email, NFact, Fecha_Fact,
SubTotalF, NA, TotalFfrom Clientes inner join Facturas on Clientes.Id_Clientes=Facturas.Id_Cliente
2)Interseccion
A∩B
R=Id_Cliente
Select Nombre, Dir, Tel_Conv, Tel_Cel, Email from Clientes left join
Facturas onClientes.Id_Cliente=Facturas.Id_Cliente
3) Diferencia
A-B todo lo que esta en A pero no en B.
B-A todo lo que esta en B pero no en A.
Vista, subtabla, Consulta, Query
CREATE VIEW Dif
asselect * from clientes
4) Producto Cartesiano
AxB
Evelyn> 100 26/08/2013 3500 256 3800
> 201 27/08/2013 1000 150 1150
Select distinct(Nombre), NFact, Fecha_Fact,SubtotalF, IVA, TotalF
from Clientes right join Facturas on Clientes.Id_Clientes=Facturas.Id_Cliente
OPERACIONES RELACIONALES
1) Proyeccion
π(relacion)
Ej:
π
(Clientes)
TSQL
Create viewContacts_Clientes as Select Nombre, Tel_Conv, Email from Clientes
2) Seleccion
σ(condicion)(Relacion)
condicion>Simple
>Compuesta
σ(Total=250000
3)Reunion Theta
4)ReunionNatural
5)Equireunion
6)Division
3)De toda la informacion de los vendedores de las oficinas de Tokyo
Operacion Relacional
Seleccion
σ(Vendedor)
create view VT as Select * from Vendedor
whereoficina='Tokyo'
4)Que vendedores tienen Id_23
Operacion Relacional
Seleccion
σ(Vendedor)
create view V23 as Select * from Vendedor
where Id_Vendedor='23'
5)Dar toda la informacion sobre elvendedor Brigit V.
Operacion Relacional
Seleccion
σ(Vendedor)
Create view as Select * from Vendedor
where Nombre_Vendedor='Brigit V.'
6)Operacion Relacional
Seleccion
σ= 20>(Vendedor)...
Regístrate para leer el documento completo.