0

我有下表的属性:

tblCourseInstructor CourseId int NULL, InstructorId int NULL

[b]tblCourses[/b] CourseId int IDENTITY(1,1) NOT NULL, CourseName nvarchar(100) NULL, CourseDescription nvarchar(2000) NULL

tblInstructors
InstructorId int NULL, InstructorName nvarchar(50) NULL

tblLocations LocationId int IDENTITY(1,1) NOT NULL,Location nvarchar(50) NOT NULL,Seating_Capacity int NULL,offers_inclass_training 位 NULL,offers_online_training 位 NULL,Available_Seating int NULL

tblTrainingType

TrainingTypeId int IDENTITY(1,1) NOT NULL,TrainingType nvarchar(50) NOT NULL

tblTrainingDates

DateId] int IDENTITY(1,1) NOT NULL,
trainingDates datetime NOT NULL

历史:

我们正在尝试在工作中创建一个培训包,员工可以在其中在线学习课程。

这就是为什么我们想出了上面的表格。

有一个主表,其中将存储注册用户及其课程选择详细信息。

挑战:

我们想要做的是呈现课程信息屏幕。

此屏幕将要求员工从下拉列表中选择培训地点。

选择培训地点后,该地点的培训详情会以表格形式显示。

例如,课程名称、讲师、课程描述以及课程日期和时间。

如果员工对此课程感兴趣,她/他将单击按钮注册参加此课程。

我们最大的挑战是将我上面列出的表格联系在一起,以便在查询表格时,我们能够如上所述列出课程名称、教师、地点、日期和时间等。

根据我上面列出的表格,没有任何关键可以将它们联系在一起。

换句话说,当我们进行查询时,它们之间并没有以允许连接的方式相互关联。

有人可以帮我解决我可能遗漏的问题吗?

提前非常感谢。

4

1 回答 1

0

正如您所说,用户将首先选择位置,然后将显示该位置可用的课程,所以

1 步:在 Course 表中有一个指向位置的键。请注意,在这种情况下,如果您在多个位置提供相同的课程,那么您将需要在此表中为同一课程提供那么多记录。

tblCourses 
            CourseId int IDENTITY(1,1) NOT NULL, 
            CourseName nvarchar(100) NULL, 
            CourseDescription nvarchar(2000) NULL
            LocationId int NOT NULL, (This is FK that connects to the location table)

第 2 步:使用 CourseId 将表 tblCourseInstructor 连接到 tblCourses。使用 InstructorId 将 tblCourseInstructor 连接到 tblInstructor 这些键已经存在于您的表中。

第 3 步:在 tblCourses 中添加 TrainingTypeID 以连接到 tblTrainingType。

tblCourses 的最终结构:

tblCourses 
                CourseId int IDENTITY(1,1) NOT NULL, 
                CourseName nvarchar(100) NULL, 
                CourseDescription nvarchar(2000) NULL
                LocationId int NOT NULL, (This is FK that connects to the location table)
                TrainingTypeID  int NOT NULL  (This is FK that connects to the tblTrainingType table)

因此,基于上述关系,您可以编写所需的查询,并根据前一个下拉列表中的选择来级联 UI 中的每个下拉列表。

于 2013-05-30T04:29:23.210 回答