Table of Contents
Previous Section Next Section

Testing the Database Installation

Once all the data has been input into the database, you should test the installation to check whether it worked. One of the simplest tests you can do for quick 'n' dirty testing is to use the following universal command:

SELECT * FROM Table;

This statement will simply list all available data in the selected table. However, if you want to use something a bit more refined, you can try out the following examples.

TESTING THE DATA 1
Start example

You can use this example to test whether the sample data has been inserted correctly:

SELECT Course.Name AS Course, Student.Name AS Student,
   Professor.Name AS Professor
FROM Student
   INNER JOIN (Professor
      INNER JOIN (Course
         INNER JOIN (Class
            INNER JOIN Enrollment
            ON Class.ClassID = Enrollment.ClassID)
         ON Course.CourseID = Class.CourseID)
      ON Professor.ProfessorID = Class.ProfessorID)
   ON Student.StudentID = Enrollment.StudentID
ORDER BY Course.Name;

If you used the INSERT statements available for download from the Apress Web site, then you should see the following results:

COURSE                     STUDENT           PROFESSOR
-------------------------- ----------------- ----------------
Applied Mathematics        Gary Burton       Prof. Williams
Applied Mathematics        Maria Fernandez   Prof. Williams
Applied Mathematics        Bruce Lee         Prof. Williams
Core Mathematics           Bruce Lee         Prof. Jones
Core Mathematics           Maria Fernandez   Prof. Jones
Core Mathematics           Steve Alaska      Prof. Jones
Electronics                Gary Burton       Prof. Ashby
Electronics                Maria Fernandez   Prof. Ashby
Electronics                Steve Alaska      Prof. Ashby
Electronics                Vic Andrews       Prof. Ashby
History of Computing       Gary Burton       Prof. Williams
History of Computing       Julia Picard      Prof. Williams
History of Computing       Vic Andrews       Prof. Williams
Human Biology              Emily Scarlett    Prof. Patel
Human Biology              Andrew Foster     Prof. Patel
Mediaeval Romanian         John Jones        Prof. Dawson
Mediaeval Romanian         Julia Picard      Prof. Dawson
Mediaeval Romanian         Anna Wolff        Prof. Dawson
Metallurgy                 Vic Andrews       Prof. Hwa
Metallurgy                 Andrew Foster     Prof. Hwa
Modern English Literature  Anna Wolff        Prof. Dawson
Modern English Literature  Julia Picard      Prof. Dawson
Organic Chemistry          Emily Scarlett    Prof. Ashby
Organic Chemistry          Andrew Foster     Prof. Ashby
Philosophy                 John Jones        Prof. Dawson
Philosophy                 Anna Wolff        Prof. Dawson
End example
TESTING THE DATA 2
Start example

This example will test a table with a date in it to ensure that differences between date syntax haven't led to any errors:

SELECT Student.Name AS Student,
       Course.Name AS Course,
       Enrollment.EnrolledOn AS EnrollmentDate,
       Enrollment.Grade AS Grade
FROM Course
   INNER JOIN (Class
      INNER JOIN (Student
         INNER JOIN Enrollment
         ON Student.StudentID = Enrollment.StudentID)
      ON Class.ClassID = Enrollment.ClassID)
   ON Course.CourseID = Class.CourseID
ORDER BY Student.Name;

You should see something like the following (depending on the time zone settings on your machine):

STUDENT         COURSE                    ENROLLMENTDATE  GRADE

--------------- ------------------------- --------------  -----
Andrew Foster   Organic Chemistry           9/23/2002      68
Andrew Foster   Human Biology               9/23/2002      66
Andrew Foster   Metallurgy                  9/30/2002      68
Anna Wolff      Mediaeval Romanian          9/23/2002      33
Anna Wolff      Modern English Literature   9/23/2002      65
Anna Wolff      Philosophy                  9/23/2002      63
Bruce Lee       Applied Mathematics         9/20/2002      60
Bruce Lee       Core Mathematics            9/20/2002      70
Emily Scarlett  Human Biology               9/30/2002      80
Emily Scarlett  Organic Chemistry           9/30/2002      78
Gary Burton     Electronics                 9/23/2003      68
Gary Burton     History of Computing        9/23/2003      51
Gary Burton     Applied Mathematics         9/23/2003      41
John Jones      Mediaeval Romanian          9/23/2002      62
John Jones      Philosophy                  9/30/2002      70
Julia Picard    Mediaeval Romanian          9/23/2002      70
Julia Picard    History of Computing        9/23/2002      53
Julia Picard    Modern English Literature   9/30/2002      42
Maria Fernandez Core Mathematics            9/20/2002      75
Maria Fernandez Applied Mathematics         9/20/2002      66
Maria Fernandez Electronics                 9/20/2002      76
Steve Alaska    Electronics                 9/20/2002      82
Steve Alaska    Core Mathematics            9/20/2002      66
Vic Andrews     Metallurgy                  9/23/2002      54
Vic Andrews     History of Computing        9/23/2002      78
Vic Andrews     Electronics                 9/23/2002      71
End example

Table of Contents
Previous Section Next Section