Relational Database Help!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

multiolivine
New php-forum User
New php-forum User
Posts: 3
Joined: Sat Aug 09, 2014 2:46 am

Relational Database Help!

Postby multiolivine » Sat Aug 09, 2014 3:58 am

Im a newbie in programming especially in php and mysql,i have a project, one of my problem is how to relate a teacher table to subject table. for example, I would like to register teachers and add some subjects....how it will be done?...sorry..im not good in programming...

landi
php-forum Active User
php-forum Active User
Posts: 305
Joined: Thu Mar 15, 2012 3:59 pm

Re: Relational Database Help!

Postby landi » Sat Aug 09, 2014 4:26 am

Hi,
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,
-A

multiolivine
New php-forum User
New php-forum User
Posts: 3
Joined: Sat Aug 09, 2014 2:46 am

Re: Relational Database Help!

Postby multiolivine » Sat Aug 09, 2014 6:19 am

Hi...Tnx landi...Ill try it..Godbless...


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron