File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes creating a database structure. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "creating a database structure." Watch "creating a database structure." New topic

creating a database structure.

Tanu Gulati
Ranch Hand

Joined: Oct 06, 2008
Posts: 113

i got below question on an interview recently
Create a database table and coulum structure and write a sql query for a school.
where one student can be taught by many teachers , one teacher can taught many subjects, and a student participate in learning various subjects from differnt teachers.

Management wants to generate a report on like how many students a teachers teaches and which subjects. l
1000 students 200 teachers 15 subjects.

The problem is all relation between student, teachers and subjects are N:N and
since it is N:N relation beteen student and teachers, students and subjects , teachers and subjects. i startedde creating some thing below

Student table : Stud_id, name
Teacher Table : Teacher_id , name
Subject Table : Subjet_id, subject name.

now i was thinking to have a joiner table( to achieve N:N relationship)

Joiner_Student_Teacher table : ST_id, stud_id, teacher_id.
Joiner_Student_Subject table : SS_id, Stud_id, Subject_id,
Joiner_Teacher_Subject table : TS_id, Teacher_id, Subject_id.

is this database design correct for above kind of Student-Teacher-Subject Model. please give your valuable suggestions.

Tanu Gulati
I agree. Here's the link:
subject: creating a database structure.
It's not a secret anymore!