SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Table structure

  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    cuernavaca,mexico
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Table structure

    HI,

    I've been working on a little grade system but can't decide how I should organize the data. Somebody told me that I shouldn't care about data output when planning the database, instead I should concentrate on data requirements only. So I made 3 tables: 'pupils' (p_id,p_name), 'subjects' (s_id,s_name) and 'grades' (p_id, s_id, month_no, grade) and after some experimenting ond with a little help of my friends I got as far as the following output:

    Charly (pupil's name)
    ----------Jan Feb Mar Apr May..............average
    English-----8---9-----8------------9----------8.5
    Maths------9---10---10-----10----------------9.5
    Behaviour---8---8-----9------9-----9----------8.6

    or

    English
    ------------Jan Feb Mar.........average
    Carmen------9----9----9-------- 9
    Charly-------8----9---- 8-------- 8.5
    Paul---------7----8----9---------8


    I said 'Wow' all this without unique subject_month fields, especially Charly's missing grade for English / April. But now, I would like to get something like a monthly average for all subjects for a given pupil.
    I wonder if this will be possible without the unique subject_month fields at the input side or if i must change my db structure.

    PS:Unfortunately this forum doesn't respect white spacess and the tables are a little bit shifted, after three edits of this post I hopr you forgive me on that.

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PS:Unfortunately this forum doesn't respect white spacess and the tables are a little bit shifted, after three edits of this post I hopr you forgive me on that.
    put it in a [code] block

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should be looking at JOIN's
    http://www.w3schools.com/sql/sql_join.asp

  4. #4
    SitePoint Member
    Join Date
    Sep 2004
    Location
    cuernavaca,mexico
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do you think I could get the output examples without JOINS ? The real problem is to display the data having empty months column fields as shown in my output examples. That was not much of a help here. thanks for the [code]block tip.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •