-2

私は次のテーブルを持っています

subject(id,name,sem,branch) //Detail of subject in sem and branch
teacher(id,name,dept) //detail of teacher
student_teacher_mapping(sid,tid) //primary key of student and teacher
section(id,sec) //detail of sections
subject_section_mapping(sid,secid) //primary key of subject and section

ブランチ「COMPUTERSCIENCE」、sem=3およびsection='d'のサブジェクト名と教師名を取得したい。

4

2 に答える 2

0

@Manish テーブル SUBJECT が SECTION にリンクされていることがわかります。これにより SECTION が提供され、そのテーブル SECTION は他のテーブルにリンクされていないため、ここで行き止まりがあり、データベースの設計が間違っているようです。

于 2012-09-06T10:03:52.747 に答える
0

最後に、私はあなたの助けなしでそれをやった:/

1つのテーブルで変更しました 私のテーブルは

subject(id,name,sem,branch) //Detail of subject in sem and branch
teacher(id,name,dept) //detail of teacher
section(id,sec) //detail of sections
sub_teacher_sec (subject_id,teacher_id,section_id) //primary key of subject,teacher and section

これは、科目名、教師名、および特定のブランチの学期とセクション値のセクションを取得するためのクエリです

select sub.name,t.name,se.sec from subjects as sub
  join
sub_teacher_sec as sts
  on
sts.subject_id=sub.id
 join
teachers as t
  on
sts.teacher_id=t.id
 join
section as se
   on
sts.section_id=se.id
and  sub.semester=3 and sub.branch='CSE';

表またはクエリに修正はありますか?提案してください。

于 2012-09-07T06:59:49.657 に答える