Let me start by giving a context.
I have 2 tables joined together by a many to many relationship as shown below.
In my Android application I have a need to show a list of the contents in the "JoinTable" (The join table will be filtered depending on the Table1 ID, this is the content that will be displayed to the user.)
Problem: I want the user to be able to group certain rows of the JoinTable together. I need to model this grouping system in the database so it can be queried later and the groups reappear. What is the best way to design the database with this capability?
Some more detail from a user perspective:
When a user selects an item from table one, that ID is sent to the next activity. The next activity queries the join table for the appropriate content. The way it's working now, it just shows one item per row from the JoinTable. The user should be able to for example, drag an item onto another item to group them together.
Related
I'm developing a vocab building app that stores data into an SQLite database. I have a category for different types of vocabulary, for example, a category for GMAT. Each of this category is an activity and has its own table where I store a list of default vocab. The classes for these categories all extend an abstract class full of methods for the menu option items, such as search, add, and delete vocab functionalities.
Now I have 4 categories which mean I have 4 tables in my SQLite database and an activity for each of the categories. However, I want to allow the user to be able to add new categories as they click on a button. The newly added category will be identical to the 4 categories I have already created. So any newly added category will have the same layout, menu items, and functionalities.
I have thought of one solution which is to create these categories first but make it invisible to the users and only show them to the user when the user performs an action to add new categories. In this case, I'll create the activities and tables in advance and just hide them in the beginning. However, with this solution, there will be a limit to the number of categories that the user can add, which is ok but not optimal. It also will cause me to create a lot of potentially unused activities which seems very inefficient.
I have come across posts like this and this, but it doesn't address my problem.
If I'm not clear with articulating my problem, it is like the music Spotify software, where I don't know how to allow the user to add new playlists dynamically.
Thank you so much for your help in advance!
Update: with juergen's suggestion, I can redesign my database to just have one table. So I no longer need to create tables dynamically, but I still have to find a way to create multiple instances of an activity dynamically.
After I redesigned my database according to Juergen's suggestion. I was able to get around this problem by opening a generic activity and alter it based on the extra I put in my intent. So in essence, there's just a single activity pulling and displaying data based on what the extra being passed to it is.
In one of my Parse.com classes/tables I'd like to have a column where another class/table can be stored for each row. As an example:
An User table with a Clothes row, in which a table with the name and color of each of the user's items can be stored.
I've done this using relations but was wondering if there's a way to do it without having to create another table and making a relation to it, since that creates two tables (the table itself and the relation). I'm just trying to make it so Parse.com has the least stress so querys or any method can be done in the least time.
Thanks, if I didn't make myself clear please ask.
I got one task as below
Above graph contains different cases which can be occur with the combination of two different selection.
In my application i need to put two drop-down boxes (I.E two spinners), from that two spinners user will select different values and i need to show that value as a result.
Now result after selecting two different spinners value is calculated like this , for example suppose from first spinner I am selecting Benazepril from row number 3 and Amiloride hydrochloride from row number 1, so this selection will give me result as a red symbol mention on graph, which has been marked with black cricle.
Now my question is i need to manage this entire thing on my SQLite Databse, Above description is just a graphical representation of logic, now i need to apply this logic at run time. I need to store all values And It's Combination result on my database. How to handle such situation?
Now Second query is after Selecting any case i need to show small graphical respresentation on my application for two different selection as below
So this is my query, I am not getting how to handle such situation, can any one give some nice guide for it?
Thanks
You could use a table like
create table interactions (
substance1 ..
substance2 ..
interaction ..
)
where you store all combinations and can answer your first question
An alternative approach would be using bitmaps for every row and every type of interaction.Then you have to build your query bitmap according. Every bit stands for a crossing of substance1 with substance2. You have to define the position of substance2 at an other place or table.
create table interactions (
substance
bitmap
interactiontype
....
Instead of the bitmap a string would do it too, where you use different chars for any possible interaction type at the crosspoint like "0X00X000000100".
create table interactions (
substance ..
crossreactions varchar(
)
On my (first) android app, I have a diary screen that shows a list of appointments the user has. Currently the app shows a list of appointments with the core information displayed on the list (start time, end time, etc).
In order for the user to see when they have free time between appointments, they need to painstakingly look at all the times and work out when there is a gap. I would like to create this gap visually to make it more intuitive for the user.
Currently I am using a SimpleCursorAdapter to fill the listview from an SQLite table, but to my knowledge, I cannot edit the results of a cursor (as - it is my understanding - that the cursor is only a pointer to the database, not a copy of the information).
Ideally what I would like to do is detect whenever there is a gap between appointments and insert an extra row where there is a gap (regardless of the size of the gap - just a single row). I would like this 'gap' row to state how many minutes of free time the gap contains.
What is the best approach to achieve this?
Edit: I have added my ideal layout below:
I have 2 columns of data in my database in Android application. I want to display this data via a table format in my application. Please help me.
For example, I have employeename and department coulmns in the database. I want to retrieve this data and show it in a table format like a table with 2 columns. One side employeename and next column their respective department in my Android application.
Unless you want user interact with the table, you can use webview and make it load table html. Advantage of this method is that you can make it as fancy as you want.
If you want interaction with the table, you'd better use listview with customized row layout, or even gridview would work too.