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 6582247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:15:24+00:00 2026-05-25T16:15:24+00:00

I have 4 tables in my SQLite database. One with questions, one with answers

  • 0

I have 4 tables in my SQLite database. One with questions, one with answers with question id foreign key, one category table, and one question-category table that holds a many-to-many relationship between the questions and categories (Each question can belong to multiple categories).

So, in my Android application I want to extract one question at the time, with all the data belonging to it. I need help with how to handle it properly. Should I make one method in my Data Access Object which is named something like getQuestionSet(int questionId) that delegates further method invocations to the question table, answer table etc. with the questionId as a where-clause? Or should I make a view that already has this sql-query saved? But then will have several rows containing the question-text because there are 4 answers belonging to each question. Or are there other solutions?

Also, if I need to do the first approach, do I make an Data Transfer Object that carries Cursor references around?

  • 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-25T16:15:25+00:00Added an answer on May 25, 2026 at 4:15 pm

    Always try to perform a single query on the database whenever possible, it is much faster and requires less effort to manage. You can use an INNER JOIN operation to get both the question and answers in a single Cursor. The result might contain duplicate data but there is no harm in that. Your result cursor might look like:

    _id, answer, question
    1, Answer 1 Text, Question Text
    2, Answer 2 Text, Question Text (same Question as above)
    3, Answer 3 Text, Question Text (same Question as above)
    

    You know that in this query the question text is always the same so you can just read it from the first row and ignore the others.

    Making a view or not is up to you, but it probably isn’t necessary.

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

Sidebar

Related Questions

I have an SQLite database. I created the tables and filled them with a
I have a DataTable which I want to save to a SQLite Database Table.
I have created a Python module that creates and populates several SQLite tables. Now,
I have an SQLite table that contains a BLOB I need to do a
I have a database that I built in SQLite browser, and it works fine.
All tables in the database have one timestamp column [ float ] followed by
I have an application that uses a SQLite database and everything works the way
C# (.NET 3.5) I have an SQLite database with two tables - employees (the
I have two table views displaying the data from a Sqlite database. I can
I have a simple sqlite database with two tables. When I manually delete (using

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.