at the stored procedure or at the browser level

  • I am working on a project for displaying employee vacations and time offs in a calendar view. the database is SQL server 2008. I have a table with employee information ( such as emp#, Name) and time off (date). pretty basic. I am using JavaScript + PHP to display the information.

    my stored procedure is simple. It creates a table in the format of

    emp#|Name|date

    -----------------

    9901 |John |2010/11/1

    9901 |John |2010/11/3

    based on starting date and ending date sent from the browser

    I am trying to display it in the browser in this manner:

    November |1|2|3|4

    ---------------

    John |Y|N|Y|Y

    Mike |Y|Y|N|N

    :-)I just want to make sure that I am correct since my boss is telling me that the table format to be displayed in the browser must be already achieved at the stored procedure level as it is more efficient since no rendering is required by the JavaScript when reading it. I basically think that it does not matter since even if I were to do it like he thinks it should be, I will still have to go through the rows and columns and render it in the browser. Also it is not like is pulling millions of records, it is a number between 20-60 as our company staff number is small.

    What you think?

  • Formatting belongs in the UI. How you deliver the data to the UI, that may differ.

  • As Lynn implied, SQL is not the place to to this.

    The correct way to format the data is to do it in your PHP page, and there should be no need to use any Javascript. I suspect your boss is, shall we say, misinformed 🙂

  • I'll "third" that. While you could do something like this in the database, it's going to be overly complex. Presentation in the presentation layer.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I agree with you guys on that as this is what I thought as well. His thought was that PHP will be doing most of the rendering/presentation and it would be an overload. But I don't believe he sees the big picture. Even if I would format the table at the database level to look like what he wants I would still have to present it ( fetching rows and iterating through their columns) in a calendar view anyway doing the same amount of work.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply