Results 1 to 11 of 11

Thread: dynamic table creaton

  1. #1
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default dynamic table creaton

    Hi,

    I am looking for a way to create dynamic tables in the database. In my app I have to store the user data to a table after every session. And the table should be different for every new session. I am thinking of creating a table name as an Index and increment it for every new session. This is just my thought. So I just wanted to know if it is possible or any other good ways to make this workable. I would be thankful for any suggestions. I want to use Sqlite database.

    Thank You,
    Baluk

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dynamic table creaton

    You can name your tables any way the database engine lets you. There is no "right" or "wrong" approach here, it all depends on what you need those tables for. It might be worth naming them by date or by the name of the user (if you have multiple users).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: dynamic table creaton

    hi,
    I am looking for a way to create dynamic tables in the database. In my app I have to store the user data to a table after every session. And the table should be different for every new session. I am thinking of creating a table name as an Index and increment it for every new session. This is just my thought. So I just wanted to know if it is possible or any other good ways to make this workable. I would be thankful for any suggestions. I want to use Sqlite database.
    can u explain it in detailed???


    Bala

  4. #4
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dynamic table creaton

    OKe. Suppose If i have created a table with name "1" in the first session. The next time when a new session starts a new table should be created let's say "2" in the same database. For the third session it should be "3". All this has to be done dynamically without writing a table name manually in the sql statement. I hope my explanation gives you an idea about my problem.

    Since the user is same I can't use name and With the date is also a problem when a user uses more than 1 time in a day. May be I will have to go with the both date and time.
    Last edited by baluk; 30th November 2010 at 12:53.

  5. #5
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Thumbs up Re: dynamic table creaton

    hi balu,
    May be I will have to go with the both date and time.
    yeah table with Datetime will be a good idea,

    or u can create log table which stores all the table creation details and u can take the id from the log table.
    ex:
    DynamicLog(tabid int,timestamp datetime,userid int);
    for the first time , this table will be empty. and when the user logs in, say tabel name 1 is created with the values inserted into the DynamicLog(1,time,userid);
    then when the user again logs in , take DynamicLog's max(tabid)+1 and create the table with that id

    hope it helps
    Bala

  6. The following user says thank you to BalaQT for this useful post:

    baluk (30th November 2010)

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dynamic table creaton

    Quote Originally Posted by baluk View Post
    OKe. Suppose If i have created a table with name "1" in the first session. The next time when a new session starts a new table should be created let's say "2" in the same database. For the third session it should be "3". All this has to be done dynamically without writing a table name manually in the sql statement. I hope my explanation gives you an idea about my problem.

    Since the user is same I can't use name and With the date is also a problem when a user uses more than 1 time in a day. May be I will have to go with the both date and time.
    Ok, but what exactly is the problem? You don't know how to insert the table name into sql statement or what?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dynamic table creaton

    Thank you for the suggestions. I am aware of Sql statements but I thought the Datetime is not very user friendly name to tables. That is why I was looking for some suggestions. Now my problem is solved.

    Thank you,
    Baluk

  9. #8
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamic table creaton

    Quote Originally Posted by baluk View Post
    Hi,

    I am looking for a way to create dynamic tables in the database. In my app I have to store the user data to a table after every session. And the table should be different for every new session....
    Sorry for my vocabulary but it is stupid Why are You want to use this crazy idea ???

  10. #9
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dynamic table creaton

    Its oke. My app helps to record ratings for videos from the users viewed in my app. And these scores to be saved to a table in a database. So I have to make a new table for every user who takes the test but we don't care of usernames.

    And I have another question about restarting my app. Since many users takes the test i have to exit and start the application for each user. Is there any way I can restart the application (starting new session)without closing and open it again.

    Thank You,

    Baluk
    Last edited by baluk; 30th November 2010 at 16:26.

  11. #10
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamic table creaton

    And how You will take some statistics from 10000 tables in example ?
    You need ONLY one table with additional column with session_id.

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dynamic table creaton

    Quote Originally Posted by baluk View Post
    Its oke. My app helps to record ratings for videos from the users viewed in my app. And these scores to be saved to a table in a database. So I have to make a new table for every user who takes the test but we don't care of usernames.
    No, you don't "have to". You can have one table with an additional column storing session id and that's it.

    And I have another question about restarting my app. Since many users takes the test i have to exit and start the application for each user. Is there any way I can restart the application (starting new session)without closing and open it again.
    If there is such limitation then you have imposed it yourself. You can redesign your application to get rid of such constraint.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 5
    Last Post: 3rd April 2010, 04:07
  2. Table Widget Vs. Table View
    By winston2020 in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2008, 09:56
  3. Dynamic QLabels
    By rajeshs in forum Qt Programming
    Replies: 3
    Last Post: 30th May 2008, 11:26
  4. Replies: 9
    Last Post: 21st June 2007, 10:27
  5. Dynamic updates to a table widget
    By guiGuy in forum Qt Programming
    Replies: 6
    Last Post: 1st June 2006, 20:24

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.