Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    92
    Thanks
    8
    Thanked 0 Times in 0 Posts

    mysql table structure

    Hello,

    I am new to mysql . I want to create a table for entering 12 months and 31 days infront of it. I am not getting how structurise it.

    In left hand side i should get all the months name and infront of each month i will enter 31 days each.

    attached the screenshot for the table design how it should look like



    Someone plz suggest me how to structurise it.
    Attached Thumbnails Attached Thumbnails mysql table structure-table.png  

  • #2
    New Coder
    Join Date
    Jan 2011
    Posts
    92
    Thanks
    8
    Thanked 0 Times in 0 Posts
    can somebody help me in this?

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,044
    Thanks
    2
    Thanked 316 Times in 308 Posts
    Your picture isn't of a database table design, its a spreadsheet of something.

    In database designs, you only store data that exists, you don't make cells for each possible piece of data.

    In general, your mysql table would have columns for an auto-increment id (an identifier to reference the data by), the date (stored as a mysql DATE data type: yyyy-mm-dd), a column to hold the data for that date, and any other columns that are relevant to the piece of data, such as a user_id the value is associated with.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #4
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,874
    Thanks
    2
    Thanked 164 Times in 159 Posts

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,550
    Thanks
    78
    Thanked 4,382 Times in 4,347 Posts
    I mildly disagree with CFMaBiSmAd about the design for this particular table.

    If you will only have one piece of data *PER DATE*, then the date itself is the perfect PRIMARY KEY and adding an auto_increment field will help nothing at all. It will just be more data added to the table for no purpose.

    So basically, I think your entire table design is this:
    Code:
    CREATE TABLE dataByDate (
        theDate DATE NOT NULL PRIMARY KEY,
        someData VARCHAR(500) 
    ) ENGINE INNODB;
    The data type for somData is something I just guessed at. You don't tell us what KIND of data you want to store for each date. Tell us that, then we can help more.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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