SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Any suggestion for this situation?

    I'm given this chart in excel thats 10x10 cells in size.
    I'm wondering if i should create the table as per in the excel file, or should i create the table as in header, side, and value columns instead?

    I've included an image to illustrate it better.



    The top left is an example of the given chart in excel (scaled down of course).

    Bottom right is what I could think of so I could reference the values by checking header and side = a certain values.
    The header D is just to show that the inputs can jumble around as long as the rows are fixed etc, header (D) = side (2) = value (i).

    but i could reference the values in the original format too. by referencing a col to the side value.

    so which one goes?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The first chart can be turned into a relational table directly.

    Code:
    CREATE TABLE `table` (
      ID INT,
      A sometype,
      B sometype,
      C sometype,
    ...
    );
    
    INSERT INTO `table` (ID, A, B, C...) VALUES (1, 'a', 'b', 'c'...);
    INSERT INTO `table` (ID, A, B, C...) VALUES (2, 'f', 'g', 'h'...);
    INSERT INTO `table` (ID, A, B, C...) VALUES (3, 'k', 'l', 'm'...);
    I don't think you should do the second thing. You already have it in the normal format.

  3. #3
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks Dan,
    would like to hear any more comments?

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Dan Grossman View Post
    I don't think you should do the second thing. You already have it in the normal format.
    what does "normal format" mean here?

    if you are referring to database normalization, then the second approach is correct, and the first one fails 1NF
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually i tot both could work. just that maybe the 1st (top left) is not scalable. but i don't need to change the table other than the values. so, not much diff imo.

    wanted to get some views on this, in case i missed something.


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
  •