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

  • Home
  • SEARCH
  • 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 3669958
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:18:22+00:00 2026-05-19T02:18:22+00:00

I am using a SQLite to store data in Android application . I need

  • 0

I am using a SQLite to store data in Android application . I need to dump data from a file having relationship between 2 places . e.g.

The table will have the following fields

Location1 Location2 Distance

X Y 12

X Z 13

Y X 12

if I dump data as a row , then I am duplicating the data i.e. the distance between the location X & location Y . I am dumping twice , once from X to Y & the other from Y to X , but it will be help me in making the SQL query as I can directly give the Location1 & Location 2 value & get the distance.

If I want to avoid the duplication of data , how can I proceed ?
I will enter only once data between location 1 & 2 but how will I write the select query.

If anyone has any suggestions/sample code regarding the database structure & the queries , kindly post them.

Also which approach will give me a faster processing incase of Android applications

Warm Regards,

CB

  • 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-19T02:18:23+00:00Added an answer on May 19, 2026 at 2:18 am

    I’m not 100% clear what you’re asking. You are saying that you are duplicating data because the difference between the two fields Location1 and Location2 is the same thing as the Distance field? If that’s the case then you could just keep Location1 and Location2. If you need the difference make your query like so:

    SELECT abs(Location1 - Location2) FROM [table] WHERE [whatever]
    

    “abs” gives you the absolute value.

    As far as processing times, I feel like this would be slower than having the Distance field in the table, but then we go back to your duplicate problem.

    Does that help? Or did I misinterpret your question?

    UPDATE
    I think I understand. You have a bunch of locations V, W, X, Y, Z, etc. The user will select from dropdown boxes Location1 and Location2, then your app will supply the distance between the two.

    So say the user selects Y for Location1 and W for Location2, your app will then return Y – W.

    You are over-complicating this. Your database only needs a record for every location ie:

    LocationName | LocationCoordinates
              V                (x, y)
              W                (x, y)
              X                (x, y)
              Y                (x, y)
              Z                (x, y)
    

    Then when the user selects Location1 and Location2, simply pull the LocationCoordinates from the database and then get the difference. Depending on how you have the locations stored in the database, you can even do the whole thing within SQL. But for now I’d suggest you just use a SELECT statement to get the locations and find the difference(distance) from within your code.

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

Sidebar

Related Questions

I am using an sqlite database to store log data. My table has a
I need to pass some binary data between two android apps using Content Provider
Using SQLite from .net, Is there a way to access the .dump command or
I am using sqlite with python. When i insert into table A i need
I'm working on an Android application that stores data in a SQLite database. My
I'm using CoreData (with SQLite as the store) in an iOS 4 iPhone application
I've got 2 applications using Core Data with a sqlite persistent store. I've got
I have a SQLite DB that I'm using to store app data, and I
I am new to android. I am using a database to store my data.
I'm using SQLite to store my data. I'm writing wrapper class, and I want

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.