SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Wheelersburg
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Counting number of tables in a database

    Hey guys,

    I am creating a forum, and am gonna put a new table for each forum I create, so whenever I need to know how many forums there are, how can I count the number of tables in a database using a like too

    Or:

    Count Number_of_tables in database where the table starts with forum?

    because I would be naming them:

    forum_1
    forum_2

    etc.

  2. #2
    SitePoint Addict
    Join Date
    May 2003
    Location
    Auckland
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Schwalbach
    Hey guys,

    I am creating a forum, and am gonna put a new table for each forum I create, so whenever I need to know how many forums there are, how can I count the number of tables in a database using a like too

    Or:

    Count Number_of_tables in database where the table starts with forum?

    because I would be naming them:

    forum_1
    forum_2

    etc.
    Are you sure thats the design you want to go for? Why do you need a separate table for each forum and not just add a 'ForumID' field to your thread/post table?

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Wheelersburg
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just wanted to do it that way, was easier. Does it cause a problem with performance or something?

    I figured when doing this, it would mean a lot less searching, because if I have say 10 forums and each one has a bunch of posts, then it has to search through all ten of those forums when looking for a post. You know what I mean?

    If the counting of tables is impossible, I will just do it that way(the way you suggested)

  4. #4
    SitePoint Addict
    Join Date
    May 2003
    Location
    Auckland
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But what if a use wanted to search all forums for a topic?

    that would mean you'd need to run 10 differenent queries on 10 different tables...

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Wheelersburg
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I decided on the one table thing, thanks alot guys


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
  •