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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:25:26+00:00 2026-06-04T21:25:26+00:00

I am trying to create a table to only has a foreign key, not

  • 0

I am trying to create a table to only has a foreign key, not a primary key. I am getting this error:

java.lang.IllegalArgumentException: column '_id' does not exist

I read a tutorial that the primary key must be _id, with no explanation. And that is fine. But what if I do not want a primary key! What if I only want a foreign key. I am assuming this is where my problem lies. The schemas below are what I have. But the third one is where I assume this is coming from.

database.execSQL("CREATE TABLE events (" +
            "_id INTEGER PRIMARY KEY, event_name TEXT" +
            ")");

database.execSQL("CREATE TABLE reminders(_id INTEGER PRIMARY KEY, event_name TEXT" +
            ")");

database.execSQL("CREATE TABLE events_info (_id INTEGER, event_name TEXT, all_day INTEGER, " +
                    "start_date INTEGER, start_time INTEGER, end_date INTEGER, end_time INTEGER," +
                    " location TEXT, reminder_id INTEGER, notes TEXT, repeat TEXT," +
                    "FOREIGN KEY(_id) REFERENCES events(_id), FOREIGN KEY(reminder_id) REFERENCES reminders(_id))"
                    );
  • 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-06-04T21:25:28+00:00Added an answer on June 4, 2026 at 9:25 pm

    Are you using a CursorAdapter? Because if you are, the CursorAdapter class requires that there is a column named _id or else the class will not work. In general, it’s often considered good practice to have your database tables contain a column named _id for this reason, in case you ever decide to bind your data to a CursorAdapter or one of its subclasses.

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

Sidebar

Related Questions

I am trying to create a table which is unique and has primary key.
I am getting this error while trying to create my app structure with story
I'm trying to create a Users table that only has OpenId registrations, exactly like
Am trying to create a NETEZZA table which has only the most recent records
I am trying this code CREATE TABLE #t ( nam Varchar(100) ) INSERT INTO
I'm trying the following: CREATE TABLE Table1 ( RecordNo autonumber, --error here! PersonId varchar(50),
I'm trying to show only brand instances which the current user has not tagged,
Trying to create a table with a bigint column creates a standard integer column
I'm trying to create a table with a timestamp column. The problem is, I
I am trying to create a table using CGI.pm. The table would contain results

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.