Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Guidance needed to produce report
Old 11-18-2008, 02:57 PM Guidance needed to produce report
Junior Talker

Posts: 4
Name: Rcardo
Trades: 0
Hi there,

As the title of this topic illustrates, i'm having trouble dumping relevant data from columns of different tables. Using isql*plus, I have three tables appropriatly related. A 'course' table, 'student' and 'next_of_kin' tables. I have many students enrolled on various courses but only a hanfull of courses offer the module option 'Database Systems'. I have no 'module' table but i know the three course names which provide the module option. I intend on producing a report hich lists all students enrolled on the courses which provid the module option 'Database Systems'. I have attempted the report but i keep getting a 'cartesian product' displaying all next_of_kin names instead of the appropriate. Also i am struggling to come up with the right WHERE statement to depict only the three courses which provide the module option 'Database Systems' as defined by 'courseNo' in both 'course' and 'student' tables.

Here is the most recent attempt:

--set echo off
--set pagesize 24
--set feedback off
--set linesize 78

col A format 99999999 heading 'Student No'
col B format A15 heading 'Student Name'
col C format A15 heading 'Course Name'
col D format 99999999 'Course No'
col E format A10 heading 'Next-of-Kin'
break on A skip 1 on B

TTitle 'Business Studies 1 Option BT300'
BTitle 'Prepared By : Richard Stroud / 20527796'

Select student.StudentNo "Student No",
student.fName || ' ' || student.lName "Student Name",
course.title "Course Name",
course.courseNo "Course No",
next_of_kin.fName || ' ' || next_of_kin.lName "Next-of-Kin"

From student, course, next_of_kin
where course.courseNo = '12885545'

order by studentNo

--clear columns
--TTitle off
--BTitle off
--set feedback on
--set pagesize 24
--clear breaks

Any help towards this toipic will be GREATLY appreciated
stroodle is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-18-2008, 04:15 PM Re: Guidance needed to produce report
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
You have to tell the database how the tables you want it to read from are related. The way your query is written, it's going to match every student with every next of kin, and match the Cartesian product with a particular course. You've explicitly limited the query to only one course, but you haven't given any guidance on how to pull only the students, etc, that are relevant for your report.

This needs a join clause. I'm guessing that there's a many to many relationship between students and courses (a student can take many courses, a course can be taught to many students), and that your next of kin table doesn't map between them. There's probably another table, ideally with a name like students_in_courses, that tells you student #1 is taking course #1 and course #2, whereas student #2 is taking course #38, etc. You'll need this in your query, to limit the Cartesian product you're seeing.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Guidance needed to produce report
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.51471 seconds with 12 queries