Relational Database Help!

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
php-forum Active User
php-forum Active User
Posts: 388
Joined: Thu Mar 15, 2012 3:59 pm

Sat Aug 09, 2014 4:26 am

Probably not the best place to ask, but...

Tables are related by a common key. In your case you probably want 3 tables:
1) The teacher table with a primary key of l_teacher_id with other columns such as t_teacher_name, dt_joined, etc with values such as (171, 'Prof Smith', '12-Aug-1996'), (172, 'Miss Jones', '1-1-12')

2) The subject table with primary key t_subject_id, and othe rcolumns like t_subject_name with values ('WW101', 'Wood Work 101') ('ENG302', 'English 302')

3) The teacher_subject table that links the two other tables like this: l_teacher_id, t_subject_id with values like this:
(171, 'WW101') [means Prof Smith takes Woodwork 101]
(171,'ENG302') [means the Prof also takes English 302]
(172,'ENG302') [means Miss Jones takes English 302]

Hope that helps,

Post Reply