3 Replies - 370 Views - Last Post: 27 November 2016 - 03:55 PM

#1 ahmedba  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 141
  • Joined: 24-January 14

How to add class to table InstructorCourses

Posted 27 November 2016 - 06:36 AM

I need to make schedule for Instructor include
day,time,date time,courses,classes(lab or class room),instructor

so that i designed my database as following
my relations as following
Instructor with courses many to many
class with instructor many to many
Relation between class and instructor many to many because instructor can teach in more classroom and class room can have more instructor

CREATE TABLE [dbo].[Courses](
    [CourseID] [int] IDENTITY(1,1) NOT NULL,
    [CourseName] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_dbo.Courses] PRIMARY KEY CLUSTERED 
(
    [CourseID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[Class](
    [ClassID] [int] IDENTITY(1,1) NOT NULL,
    [ClassName] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_dbo.Class] PRIMARY KEY CLUSTERED 
(
    [ClassID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[Instructor](
    [InstructorID] [int] IDENTITY(1,1) NOT NULL,
    [IstructorName] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_dbo.Instructor] PRIMARY KEY CLUSTERED 
(
    [InstructorID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[InstructorCourses](
    [CourseID] [int] NOT NULL,
    [InstructorID] [int] NOT NULL,
    [fromtime] [nvarchar](50) NULL,
    [totime] [nvarchar](50)  NULL,
    [day] [nvarchar](50) NULL,
 CONSTRAINT [PK_dbo.InstructorCourses] PRIMARY KEY CLUSTERED 
(
    [CourseID] ASC,
    [InstructorID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[Instructor_Class](
	[ClassID] [int] NOT NULL,
	[InstructorID] [int] NOT NULL,
 CONSTRAINT [PK_dbo.Instructor_Class] PRIMARY KEY CLUSTERED 
(
	[ClassID] ASC,
	[InstructorID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


To make schedule for instructor i make relation between Instructor table and Courses table many to many and generate third table
InstructorCourses table have InstructorID and CourseID
But
How to add ClassID to table InstructorCourses although Class table have relation many to many with table Instructor

Is This A Good Question/Topic? 0
  • +

Replies To: How to add class to table InstructorCourses

#2 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2329
  • View blog
  • Posts: 9,356
  • Joined: 03-December 12

Re: How to add class to table InstructorCourses

Posted 27 November 2016 - 01:22 PM

The only hint I will give, you are thinking in the wrong direction.

Every heard of a joining table?
Was This Post Helpful? 0
  • +
  • -

#3 ahmedba  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 141
  • Joined: 24-January 14

Re: How to add class to table InstructorCourses

Posted 27 November 2016 - 03:53 PM

IF Possible can you tell me what is wrong
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2329
  • View blog
  • Posts: 9,356
  • Joined: 03-December 12

Re: How to add class to table InstructorCourses

Posted 27 November 2016 - 03:55 PM

What do you mean, what is wrong? You don't have anything for it to be wrong. Look up what a joining table is.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1