I am trying to make composite primary in TABLENAME1 key that i want to use in two different tables i.e. TABLENAME5 and TABLENAME6 is this possible? i am getting this annoying SQLiteException please help me with that i am very new to android stuff. Here is the code..
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME1 + " (teacher TEXT,course TEXT,att TEXT,PRIMARY KEY(course, att), code TEXT NOT NULL, bunk INTEGER, attend INTEGER, room TEXT)");
db.execSQL("CREATE TABLE " + TABLE_NAME2 + " (id INTEGER PRIMARY KEY, title TEXT, notes TEXT)");
db.execSQL("CREATE TABLE " + TABLE_NAME5 + " (course TEXT,bunkdate LONG,FOREIGN KEY(course) REFERENCES " + TABLE_NAME1 + "(course) ON DELETE CASCADE)");
db.execSQL("CREATE TABLE " + TABLE_NAME6 + " (course TEXT,attdate LONG,FOREIGN KEY(att) REFERENCES " + TABLE_NAME1 + "(att) ON DELETE CASCADE)");
db.execSQL("CREATE TABLE " + TABLE_NAME3 + " (id INTEGER PRIMARY KEY AUTOINCREMENT,year INTEGER, month INTEGER, day INTEGER, hour INTEGER, minute INTEGER, title TEXT, type TEXT, status INTEGER, snooze INTEGER, shakemode INTEGER, mathsolver INTEGER, sun INTEGER,mon INTEGER,tue INTEGER, wed INTEGER,thu INTEGER, fri INTEGER,sat INTEGER)");
}
and here is logcat:
08-22 01:51:44.419: E/SQLiteLog(1528): (1) near "code": syntax error
08-22 01:51:44.429: E/AndroidRuntime(1528): FATAL EXCEPTION: main
08-22 01:51:44.429: E/AndroidRuntime(1528): Process: com.smart.scheduler, PID: 1528
08-22 01:51:44.429: E/AndroidRuntime(1528): android.database.sqlite.SQLiteException: near "code": syntax error (code 1): , while compiling: CREATE TABLE campus (teacher TEXT,course TEXT,att TEXT,PRIMARY KEY(course, att), code TEXT NOT NULL, bunk INTEGER, attend INTEGER, room TEXT)