Автор работы: Пользователь скрыл имя, 28 Апреля 2013 в 04:22, курсовая работа
Цель работы:
Изучение возможностей AllFusion ERwin Data Modeler, проектирование реляционной БД на основе методологии IDEF1x.
Рис. 2. Разрешение связи "многие-ко-многим"
На логическом уровне проектирования БД существовала связь «многие-ко-многим» между сущностями Отделение и Клиент. В результате перехода на физический уровень образовалась дополнительная сущность с соответствующей областью первичных ключей:
Рис.3 Переход на физический уровень
8. Скрипт для создания БД в Access:
' Starting Access Basic DAO Session...
Dim ERwinWorkspace As Workspace
Dim ERwinDatabase As Database
Dim ERwinTableDef As TableDef
Dim ERwinQueryDef As QueryDef
Dim ERwinIndex As Index
Dim ERwinField As Field
Dim ERwinRelation As Relation
Set ERwinWorkspace = DBEngine.WorkSpaces(0)
Set ERwinDatabase = ERwinWorkspace.OpenDatabase(
' CREATE TABLE "Client"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("ID client", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID enterprise", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
' CREATE INDEX "PrimaryKey"
Set ERwinTableDef = ERwinDatabase.TableDefs("
Set ERwinIndex = ERwinTableDef.CreateIndex("
Set ERwinField = ERwinIndex.CreateField("ID client")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("ID enterprise")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("Number of flat")
ERwinIndex.Fields.Append ERwinField
ERwinIndex.Primary = True
ERwinTableDef.Indexes.Append ERwinIndex
' CREATE TABLE "Department"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("ID department", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
' CREATE INDEX "PrimaryKey"
Set ERwinTableDef = ERwinDatabase.TableDefs("
Set ERwinIndex = ERwinTableDef.CreateIndex("
Set ERwinField = ERwinIndex.CreateField("ID department")
ERwinIndex.Fields.Append ERwinField
ERwinIndex.Primary = True
ERwinTableDef.Indexes.Append ERwinIndex
' CREATE TABLE "Department_Client"
Set ERwinTableDef = ERwinDat base.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("ID department", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID client", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID enterprise", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
' CREATE INDEX "PrimaryKey"
Set ERwinTableDef = ERwinDatabase.TableDefs("
Set ERwinIndex = ERwinTableDef.CreateIndex("
Set ERwinField = ERwinIndex.CreateField("ID department")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("ID client")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("ID enterprise")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("Number of flat")
ERwinIndex.Fields.Append ERwinField
ERwinIndex.Primary = True
ERwinTableDef.Indexes.Append ERwinIndex
' CREATE TABLE "Enterprise-sender"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("ID enterprise", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
' CREATE INDEX "PrimaryKey"
Set ERwinTableDef = ERwinDatabase.TableDefs("
Set ERwinIndex = ERwinTableDef.CreateIndex("
Set ERwinField = ERwinIndex.CreateField("ID enterprise")
ERwinIndex.Fields.Append ERwinField
ERwinIndex.Primary = True
ERwinTableDef.Indexes.Append ERwinIndex
' CREATE TABLE "Function"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("ID function", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID work place", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID sector", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
' CREATE INDEX "PrimaryKey"
Set ERwinTableDef = ERwinDatabase.TableDefs("
Set ERwinIndex = ERwinTableDef.CreateIndex("
Set ERwinField = ERwinIndex.CreateField("ID function")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("ID work place")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("ID sector")
ERwinIndex.Fields.Append ERwinField
ERwinIndex.Primary = True
ERwinTableDef.Indexes.Append ERwinIndex
' CREATE TABLE "Housing estate"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
' CREATE INDEX "PrimaryKey"
Set ERwinTableDef = ERwinDatabase.TableDefs("
Set ERwinIndex = ERwinTableDef.CreateIndex("
Set ERwinField = ERwinIndex.CreateField("Number of flat")
ERwinIndex.Fields.Append ERwinField
ERwinIndex.Primary = True
ERwinTableDef.Indexes.Append ERwinIndex
' CREATE TABLE "Motor transport"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID department", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
' CREATE INDEX "PrimaryKey"
Set ERwinTableDef = ERwinDatabase.TableDefs("Motor transport")
Set ERwinIndex = ERwinTableDef.CreateIndex("
Set ERwinField = ERwinIndex.CreateField("State number")
ERwinIndex.Fields.Append ERwinField
ERwinIndex.Primary = True
ERwinTableDef.Indexes.Append ERwinIndex
' CREATE TABLE "Permit"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("ID permit", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID client", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID enterprise", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
' CREATE INDEX "PrimaryKey"
Set ERwinTableDef = ERwinDatabase.TableDefs("
Set ERwinIndex = ERwinTableDef.CreateIndex("
Set ERwinField = ERwinIndex.CreateField("ID permit")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("ID client")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("ID enterprise")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("Number of flat")
ERwinIndex.Fields.Append ERwinField
ERwinIndex.Primary = True
ERwinTableDef.Indexes.Append ERwinIndex
' CREATE TABLE "Sector"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("ID sector", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID department", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
' CREATE INDEX "PrimaryKey"
Set ERwinTableDef = ERwinDatabase.TableDefs("
Set ERwinIndex = ERwinTableDef.CreateIndex("
Set ERwinField = ERwinIndex.CreateField("ID sector")
ERwinIndex.Fields.Append ERwinField
ERwinIndex.Primary = True
ERwinTableDef.Indexes.Append ERwinIndex
' CREATE TABLE "Work place"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("ID work place", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID sector", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef
' CREATE INDEX "PrimaryKey"
Set ERwinTableDef = ERwinDatabase.TableDefs("Work place")
Set ERwinIndex = ERwinTableDef.CreateIndex("
Set ERwinField = ERwinIndex.CreateField("ID work place")
ERwinIndex.Fields.Append ERwinField
Set ERwinField = ERwinIndex.CreateField("ID sector")
ERwinIndex.Fields.Append ERwinField
ERwinIndex.Primary = True
ERwinTableDef.Indexes.Append ERwinIndex
' CREATE TABLE "Worker"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("
Set ERwinField = ERwinTableDef.CreateField("ID of worker", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID work place", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("ID sector", DB_INTEGER)
ERwinField.Required = True
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("