Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7624813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:04:09+00:00 2026-05-31T05:04:09+00:00

I’m new to databases and web development but I’m trying my best to learn

  • 0

I’m new to databases and web development but I’m trying my best to learn my way though making my own dynamic website. I’m taking it step by step and am currently designing the data model on paper. I’m wonder how does one structure a database for a website that allows voting like how stackoverflow does it? If there’s a table that contains a list of questions, each question that a user creates gets added to this table. There can’t simply be a field on this table that counts votes because that would allow a single person to have unlimited votes right? So there should be a key that connects to another table which counts votes and keeps track of users so they can’t vote twice, correct? If this is true, this is the part where I get confused. Each answer given can also be voted on. So does that mean that when a user submits an answer, in addition to adding that answer to probably a separate table for answers per question asked, the model must also generate a new table for each answer dynamically during run-time to keep track of all these votes?

Note that I’m not specifically asking about how stackoverflow does it, but how the concept of what the user experiences works.

One thing I’d also like to do is query the activity of a single user, so if all these tables would have to be created dynamically for every piece of submitted data, creating a crap load of tables over time, wouldn’t it be really slow to have to parse through every table to check if a particular user submitted any data or voted?

Is there a better way of doing this that someone could explain in laymen terms? No need for specific code… I can probably figure that out later when the time comes. I’m just theorizing right now and building a paper model to work off of later.

EDIT: Oh, I see. I think in excel-like spreadsheets when I’m thinking of database tables, so correct me if my understanding is wrong. So every vote site-wide is on a single table (listed vertically on a spreadsheet), each having a line of data (horizontally) that links the vote to a variety of owners (user and question OR answer)? Is that correct? I say question OR answer because I don’t understand a scenario where it would make sense to have them both as a vote attribute(not sure if that’s correct terminology) instead of creating two separate vote datas for an answer and a question which are both being voted on. Basically the way I see it, each line represents a vote and there are 3 fields, 1. Value (+1 or -1), 2. From whom (username), 3. To what (question or answer).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:04:11+00:00Added an answer on May 31, 2026 at 5:04 am

    You have to look at all the elements. Basically you have

    Questions
    Users
    Answers
    Votes
    

    Users are tied to Questions and answers and votes so you will either need adequate foreign keys to handle this or a child table that connects these. For instance you could have

    tblQuestions
        questid
        question
        userid
    

    then

    tblAnswer
        Answer
        answerid
        userid
        questid 
        accepted (to flag as accepted answer)
    

    and finally

    tblVote
        vote (up or down)
        questid
        answerid
        userid
    

    The user table is fairly straightforward and the fun part happens in the behind the scenes logic. this is obviously a very rough layout and a lot of other things need to be considered and there are dozens of ways to accomplish the table layout.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.