PRACTICA V-23. DDL
utilizando DAO: creacion de indices
EQUIPO No5
OBJETIVO.- continuación de la aplicación para definir una base de datos basada en el modelo relacional utilizando DDL y DAO.
PROCEDIMIENTO.- Para esta práctica el procedimiento es el siguiente:
Call Info("12: Crear indices")
Call Info(" ->
Vendedor")
Set idxVendedor = _
tbdVendedor.CreateIndex("pkVendedor")
With idxVendedor
.Fields.Append .CreateField("IDVendedor")
.Primary = True
.Unique = True
End With
tbdVendedor.Indexes.Append idxVendedor
Call Info(" ->
Venta")
Set idxVenta(1) = _
tbdVenta.CreateIndex("pkVenta")
With idxVenta(1)
.Fields.Append .CreateField("IDVenta")
.Primary = True
.Unique = True
End With
Set idxVenta(2) = _
tbdVenta.CreateIndex("fkVendedor")
With idxVenta(2)
.Fields.Append .CreateField("IDVendedor")
.Primary = False
.Unique = False
End With
With tbdVenta
.Indexes.Append idxVenta(1)
.Indexes.Append idxVenta(2)
End With
Call Info(" ->
Articulo")
Set idxArticulo = _
tbdArticulo.CreateIndex("pkArticulo")
With idxArticulo
.Fields.Append .CreateField("IDArticulo")
.Primary = True
.Unique = True
End With
tbdArticulo.Indexes.Append idxArticulo
Call Info(" -> Venta_Articulo")
Set idxVenta_Articulo(1) = _
tbdVenta_Articulo.CreateIndex("pkVenta_Articulo")
With idxVenta_Articulo(1)
.Fields.Append .CreateField("IDVenta")
.Fields.Append .CreateField("IDArticulo")
.Primary = True
.Unique = True
End With
Set idxVenta_Articulo(2) = _
tbdVenta_Articulo.CreateIndex("fkVenta")
With idxVenta_Articulo(2)
.Fields.Append .CreateField("IDVenta")
.Primary = False
.Unique = False
End With
Set idxVenta_Articulo(3) = _
tbdVenta_Articulo.CreateIndex("fkArticulo")
With idxVenta_Articulo(3)
.Fields.Append .CreateField("IDArticulo")
.Primary = False
.Unique = False
End With
With tbdVenta_Articulo
.Indexes.Append idxVenta_Articulo(1)
.Indexes.Append idxVenta_Articulo(2)
.Indexes.Append idxVenta_Articulo(3)
End With
End Sub
CONCLUSIONES: se sigue utilizando el procedimiento definido por el usuario llamado INFO, con SET estamos asignandole una referencia a la variable idxVendedor la cual va a estar contenida en la tabla tbdVendedor como un índice con clave primaria. Luego utilizamos la instrucción with para definir algunas propiedades al índice mencionado esas propiedades son por ejemplo agregarle el campo IDVendedor, hacerlo primario, y único.