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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:40:51+00:00 2026-05-30T21:40:51+00:00

I’m trying to do something simple here but my knowledge on databases and SQL

  • 0

I’m trying to do something simple here but my knowledge on databases and SQL is rusty at best.
I’m was following a tutorial here and am now trying to make my own joined table.

To explain a bit more simply, Profiles have widgets, widgets can be of multiple types.
The widget table contains an id, a name and a string widget_type. For each widget type, there will be another table for that widget_type.

So

                              Profile
                                 |
                                 |
                                 |
                               Widget
                                 |
              |------------------|--------------------|
             Widget1           Widget2              Widget3

The part I’m having trouble with is sharing the Id’s among the widgets so that they are unique across all 3 widget tables. Heres the SQL I have below but I’m not entirely sure what I’m trying to do is called or if it can be done from within SQLite

private static final String PROFILE_DATABASE_CREATE = "create table "
            + TABLE_PROFILES + "( " + COLUMN_ID
            + " integer primary key autoincrement, " + PROFILE_COLUMN_NAME
            + " text not null);";

// Widget creation SQL statement
private static final String WIDGET_DATABASE_CREATE = "create table "
            + TABLE_WIDGETS + "(" + COLUMN_ID +"integer primary key autoincrement" + WIDGET_COLUMN_TYPE +"text not null";
  • 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-30T21:40:52+00:00Added an answer on May 30, 2026 at 9:40 pm

    Urk. Hard to do this so that the IDs in Widget1 are different from the IDs in Widget2.

    A more simple way is to collapse all the tables together. The Contacts Provider that backs the People application does this. Have one table containing the data for all three widget types. Differentiate a row for a particular widget type with a unique MIME type. Add a widget by adding it to the table with the _ID value of the profile it belongs to, the MIME type for its widget type, and its data.

    The trick is to give this “generic widget” table the maximum number of columns you’d need for any type of widget. Provide some columns that are the same for any widget, and then some generic columns (say DATA1 through DATA5) whose contents vary according to the type of widget. Then assign type-specific constants for each widget type

    For example, for the Widget table you’d create these column name constants

    private static final String _ID = "_ID";
    private static final String WIDGET_NAME = "name";
    private static final String WIDGET_TYPE = "MIMEtype";
    

    then

    private static final String WIDGET1_TYPE = "vnd.example.com/widget1";
    private static final String WIDGET2_TYPE = "vnd.example.com/widget2";
    private static final String WIDGET3_TYPE = "vnd.example.com/widget3";
    

    and

    private static final String SOME_WIDGET1_COLUMN = "DATA1";
    private static final String SOME_OTHER_WIDGET2_COLUMN = "DATA2";
    

    etc.

    It really doesn’t matter if you retrieve a row of MIME type “vnd.example.com/widget1” and then access the cursor using “SOME_OTHER_WIDGET2_COLUMN”, but it’s easier to keep track of what’s going on if you use the Widget1 constants on Widget1 cursors, etc.

    If you’ve ever wondered what all the contract classes for android.provider do, well, this is it.

    • 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 trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

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.