Разработка базы данных библиотечного фонда города, страница 7

rel.ForeignTable          = "Formyl_r"

rel.Attributes              = 0

Call AddFieldToRelation("ID_sotrydnika", "ID_sotrydnika")

dbs.Relations.Append rel

'=== Create relations between parent table Chitayel_ and child table Formyl_r ======

Set rel = dbs.CreateRelation("1")

rel.Table                                        = "Chitayel_"

rel.ForeignTable          = "Formyl_r"

rel.Attributes              = 0

Call AddFieldToRelation("n_chit_bileta", "n_chit_bileta")

dbs.Relations.Append rel

'=== Create relations between parent table Chitateli and child table Chitayel_ ======

Set rel = dbs.CreateRelation("2")

rel.Table                                        = "Chitateli"

rel.ForeignTable          = "Chitayel_"

rel.Attributes              = 0

Call AddFieldToRelation("ID_kategorii", "ID_kategorii")

dbs.Relations.Append rel

'=== Create relations between parent table Chitat_zal and child table Sotrydniki ======

Set rel = dbs.CreateRelation("3")

rel.Table                                        = "Chitat_zal"

rel.ForeignTable          = "Sotrydniki"

rel.Attributes              = 0

Call AddFieldToRelation("ID_zala", "ID_zala")

dbs.Relations.Append rel

'=== Create relations between parent table Chitat_zal and child table chitatel_v_zale ======

Set rel = dbs.CreateRelation("4")

rel.Table                                        = "Chitat_zal"

rel.ForeignTable          = "chitatel_v_zale"

rel.Attributes              = 0

Call AddFieldToRelation("ID_zala", "ID_zala")

dbs.Relations.Append rel

'=== Create relations between parent table Znania and child table Kniga_jyrnal_ ======

Set rel = dbs.CreateRelation("5")

rel.Table                                        = "Znania"

rel.ForeignTable          = "Kniga_jyrnal_"

rel.Attributes              = 0

Call AddFieldToRelation("kod_oblasti_znania", "kod_oblasti_znania")

dbs.Relations.Append rel

'=== Create relations between parent table Kniga_jyrnal_ and child table Ekzempl_knigi ======

Set rel = dbs.CreateRelation("6")

rel.Table                                        = "Kniga_jyrnal_"

rel.ForeignTable          = "Ekzempl_knigi"

rel.Attributes              = 0

Call AddFieldToRelation("ID_knigi", "ID_knigi")

dbs.Relations.Append rel

'=== Create relations between parent table Gazeta and child table Podchivka ======

Set rel = dbs.CreateRelation("7")

rel.Table                                        = "Gazeta"

rel.ForeignTable          = "Podchivka"

rel.Attributes              = 0

Call AddFieldToRelation("ID_gazeta", "ID_gazeta")

dbs.Relations.Append rel

End Sub

' Add fields to table

=====================

Sub AddFieldToTable(FieldName As String, DataType As String, SizeCol As Integer, Attributes As Long, DefaultValue As Variant, ValText As String, ValRule As String, NotN As Boolean, ZeroLength As Boolean)

Dim fld As DAO.Field

Set fld = tdf.CreateField( FieldName, DataType )

If SizeCol                                     <> 0 Then fld.Size                        = SizeCol

If Attributes               <> 0 Then fld.Attributes              = Attributes

fld.Required                                                   = NotN

If DataType = dbText or DataType = dbMemo Then fld.AllowZeroLength = ZeroLength

fld.DefaultValue                          = DefaultValue

fld.ValidationRule     = ValRule

fld.ValidationText      = ValText

tdf.Fields.Append fld

End Sub

' Add properties to table

'=========================

Sub AddPropertyToTable( PropertyName As String, Value As Variant, DataType As String)