Search code examples
androidsqliteforeign-keyscreate-table

Foreign Key constraint implementation failing Android Sqlite


when i run the application no table is being created.I have tried to turn on implementation of foreign key attribute and it didnt work. If there is another way to do it would be very helpful.This is the all the code for the project im trying to do its an Patient Appointment Scheduling System.So im trying to implement the foreign key in my appoinment table as you can see down below. DatabaseHelper.java

public class DatabaseHelper extends SQLiteOpenHelper {
//columns for the Patient table
public static final String TABLE_NAME = "Patient_Reg_table";
public static final String COLUMN_PATIENT_ID= "PatientID";
public static final String COLUMN_FNAME= "FName";
public static final String COLUMN_LNAME = "LName";
public static final String COLUMN_GENDER= "Gender";
public static final String COLUMN_USERNAME = "Username";
public static final String COLUMN_PASSWORD = "Password";
public static final String COLUMN_EMAIL = "Email";
public static final String COLUMN_PNUM= "PNum";
public static final String COLUMN_PADD = "Postal_Address";
public static final String COLUMN_PROVINCE= "Province";
//column for the Doctor Table
public static final String TABLE_NAME1 = "Doctor_Reg_table";
public static final String COLUMN_DOCTOR_ID= "Doctor_ID";
public static final String COLUMN_FNAME1= "F_Name";
public static final String COLUMN_LNAME1 = "L_Name";
public static final String COLUMN_GENDER1= "Sex";
public static final String COLUMN_USERNAME1 = "Username_Doc";
public static final String COLUMN_PASSWORD1 = "Password_Doc";
public static final String COLUMN_EMAIL1 = "Email_Doc";
public static final String COLUMN_PNUM1= "PNum_Doc";
public static final String COLUMN_PADD1 = "Postal_Address_Doc";
public static final String COLUMN_PROVINCE1= "Province_Doc";
public static final String COLUMN_SPECIALITY= "Speciality";
//column for the Appointment-Booking table
public static final String TABLE_NAME2= "Appointment_table";
public static final String Appointment_ID = "Appoint_ID";
public static final String Booking_Date = "B_date";
public static final String Pat_ID="Pat_ID";
public static final String Doc_ID="Doc_ID";
public static final String Booking_TimeSlot = "B_time";
public static final String Speciality1 = "Speciality1";
//SQL statement for creation of a database
public static final String DATABASE_NAME="hit200.db";


public DatabaseHelper(Context context) {
    super(context, DATABASE_NAME, null, 1);
    SQLiteDatabase db = this.getWritableDatabase();
}
@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(" CREATE TABLE " + TABLE_NAME + " (PatientID INTEGER PRIMARY KEY AUTOINCREMENT, FName TEXT , LName TEXT , Gender, Username TEXT , Password TEXT , Email TEXT , PNum INTEGER , Postal_Address TEXT , Province)");
    db.execSQL(" CREATE TABLE " + TABLE_NAME1 + " ( Doctor_ID INTEGER PRIMARY KEY AUTOINCREMENT, F_Name TEXT , L_Name TEXT , Sex TEXT , Username_Doc TEXT , Password_Doc TEXT , Email_Doc TEXT , PNum_Doc INTEGER ,Postal_Address_Doc TEXT , Province_Doc TEXT , Speciality TEXT ) ");
    db.execSQL(" CREATE TABLE " + TABLE_NAME2 + " (Appoint_ID INTEGER PRIMARY KEY AUTOINCREMENT, b_date date, b_time date, FOREIGN KEY (PATIENT_ID) REFERENCES TABLE_NAME(PatientID), FOREIGN KEY (DOCTOR_ID,CATEGORY) REFERENCES TABLE_NAME1 (Doctor_ID,Speciality)ON DELETE CASCADE)");
    db.setForeignKeyConstraintsEnabled(true);
}


@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL(" DROP TABLE IF EXISTS " + TABLE_NAME);
    db.execSQL(" DROP TABLE IF EXISTS " + TABLE_NAME1);
    db.execSQL(" DROP TABLE IF EXISTS " + TABLE_NAME2);

}

public boolean insertData(String name, String lname, String gender , String username, String password, String email,
                           String pnum, String padd, String province)
{
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put(COLUMN_FNAME,name);
    contentValues.put(COLUMN_LNAME,lname);
    contentValues.put(COLUMN_GENDER,gender);
    contentValues.put(COLUMN_USERNAME,username);
    contentValues.put(COLUMN_PASSWORD,password);
    contentValues.put(COLUMN_EMAIL,email);
    contentValues.put(COLUMN_PADD,padd);
    contentValues.put(COLUMN_PNUM,pnum);
    contentValues.put(COLUMN_PROVINCE,province);
    long rows=db.insertWithOnConflict(TABLE_NAME, null,  contentValues,SQLiteDatabase.CONFLICT_REPLACE);
    System.out.print(rows);
    Log.d("User_cannot_to_dupliate",""+ rows);
    long result0= db.insert(TABLE_NAME,null,contentValues);
    if(result0 == -1)
        return false;
    else
        return true;
}

public boolean InsertData(String name1, String lname1, String gender1 , String username1, String password1, String email1,
                           String padd1, String province1,String pnum1,String speciality1)
{
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put(COLUMN_FNAME1,name1);
    contentValues.put(COLUMN_LNAME1,lname1);
    contentValues.put(COLUMN_GENDER1,gender1);
    contentValues.put(COLUMN_USERNAME1,username1);
    contentValues.put(COLUMN_PASSWORD1,password1);
    contentValues.put(COLUMN_EMAIL1,email1);
    contentValues.put(COLUMN_PADD1,padd1);
    contentValues.put(COLUMN_PROVINCE1,province1);
    contentValues.put(COLUMN_PNUM1,pnum1);
    contentValues.put(COLUMN_SPECIALITY,speciality1);
    long rows=db.insertWithOnConflict(TABLE_NAME, null,  contentValues,SQLiteDatabase.CONFLICT_REPLACE);
    System.out.print(rows);
    Log.d("User_cannot_to_dupliate",""+ rows);
    long result= db.insert(TABLE_NAME1,null,contentValues);
    if(result == -1)
        return false;
    else
        return true;
}
public boolean UpdateData(String id,String name, String lname, String gender , String username, String password, String email,
                          String pnum, String padd, String province)
{
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put(COLUMN_PATIENT_ID,id);
    contentValues.put(COLUMN_FNAME,name);
    contentValues.put(COLUMN_LNAME,lname);
    contentValues.put(COLUMN_GENDER,gender);
    contentValues.put(COLUMN_USERNAME,username);
    contentValues.put(COLUMN_PASSWORD,password);
    contentValues.put(COLUMN_EMAIL,email);
    contentValues.put(COLUMN_PADD,padd);
    contentValues.put(COLUMN_PNUM,pnum);
    contentValues.put(COLUMN_PROVINCE,province);
    db.update(TABLE_NAME ,contentValues,"ID= ?", new String []{id});
    return  true;
}
public boolean UpdataData1(String id1,String name1, String lname1, String gender1 , String username1, String password1, String email1,
                           String padd1, String province1,String pnum1,String speciality1)
{
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put(COLUMN_DOCTOR_ID,id1);
    contentValues.put(COLUMN_FNAME1,name1);
    contentValues.put(COLUMN_LNAME1,lname1);
    contentValues.put(COLUMN_GENDER1,gender1);
    contentValues.put(COLUMN_USERNAME1,username1);
    contentValues.put(COLUMN_PASSWORD1,password1);
    contentValues.put(COLUMN_EMAIL1,email1);
    contentValues.put(COLUMN_PADD1,padd1);
    contentValues.put(COLUMN_PROVINCE1,province1);
    contentValues.put(COLUMN_PNUM1,pnum1);
    contentValues.put(COLUMN_SPECIALITY,speciality1);
    db.update(TABLE_NAME1 ,contentValues,"ID= ?", new String []{id1});
    return  true;
}
public Integer DeleteData(String id)
{
    SQLiteDatabase db=this.getWritableDatabase();
    return db.delete(TABLE_NAME, "ID = ?",new String[] {id});

}

}


Solution

  • There a few issues the first is with the FOREIGN KEY's. You are saying that the constraint should apply to column PATIENT_ID, but haven't defined such a column in the Appointment_table.

    The logcat would have included a stack trace saying that column PATIENT_ID did not exist.

    Fixing that would then result in an error stating that TABLE_NAME does not exist as you have enclosed TABLE_NAME within the quotes so it is taken literally.

    The second FOREIGN key has similar errors. However compounded as you are attempting to utilise a, what appears to be a unnecessary COMPOSITE FOREIGN KEY. Neither the DOCTOR_ID or CATEGORY columns have been defined, TABLE_NAME1 is taken as a literal as it is enclosed within quotes. The composite columns (CATEGORY and SPECIALITY) are not needed as the DOCTOR_ID in the Doctor_Reg_table uniquely identifies the the relationship. Additionally including CATEGORY/SPECIALITY would have issues as the index requirements for FOREIGN KEYS would not be met.

    Last you cannot use the setForeignKeyConstraintsEnabled(true) in the onCreate as it run within a transaction. You could override the onConFigure method :-

    • onConfigure added in API level 16 void onConfigure (SQLiteDatabase db) Called when the database connection is being configured, to enable features such as write-ahead logging or foreign key support.

      This method is called before onCreate(SQLiteDatabase), onUpgrade(SQLiteDatabase, int, int), onDowngrade(SQLiteDatabase, int, int), or onOpen(SQLiteDatabase) are called. It should not modify the database except to configure the database connection as required.

      This method should only call methods that configure the parameters of the database connection, such as enableWriteAheadLogging() setForeignKeyConstraintsEnabled(boolean), setLocale(Locale), setMaximumSize(long), or executing PRAGMA statements. onConfigure

    The following code works and is probably what you want :-

    public class DatabaseHelper extends SQLiteOpenHelper {
        //columns for the Patient table
        public static final String TABLE_NAME = "Patient_Reg_table";
        public static final String COLUMN_PATIENT_ID = "PatientID";
        public static final String COLUMN_FNAME = "FName";
        public static final String COLUMN_LNAME = "LName";
        public static final String COLUMN_GENDER = "Gender";
        public static final String COLUMN_USERNAME = "Username";
        public static final String COLUMN_PASSWORD = "Password";
        public static final String COLUMN_EMAIL = "Email";
        public static final String COLUMN_PNUM = "PNum";
        public static final String COLUMN_PADD = "Postal_Address";
        public static final String COLUMN_PROVINCE = "Province";
        //column for the Doctor Table
        public static final String TABLE_NAME1 = "Doctor_Reg_table";
        public static final String COLUMN_DOCTOR_ID = "Doctor_ID";
        public static final String COLUMN_FNAME1 = "F_Name";
        public static final String COLUMN_LNAME1 = "L_Name";
        public static final String COLUMN_GENDER1 = "Sex";
        public static final String COLUMN_USERNAME1 = "Username_Doc";
        public static final String COLUMN_PASSWORD1 = "Password_Doc";
        public static final String COLUMN_EMAIL1 = "Email_Doc";
        public static final String COLUMN_PNUM1 = "PNum_Doc";
        public static final String COLUMN_PADD1 = "Postal_Address_Doc";
        public static final String COLUMN_PROVINCE1 = "Province_Doc";
        public static final String COLUMN_SPECIALITY = "Speciality";
        //column for the Appointment-Booking table
        public static final String TABLE_NAME2 = "Appointment_table";
        public static final String COLUMN_APPOINTMENT_ID = "Appoint_ID";
        public static final String COLUMN_BOOKING_DATE = "B_date";
        public static final String COLUMN_BOOKING_TIME = "B_time";
        public static final String COLUMN_PAT_ID = "Pat_ID";
        public static final String COLUMN_DOC_ID = "Doc_ID";
        public static final String COLUMN_BOOKING_TIMESLOT = "B_time";
        public static final String COLUMN_SPECIALITY1 = "Speciality1";
        //SQL statement for creation of a database
        public static final String DATABASE_NAME = "hit200.db";
    
    
        public DatabaseHelper(Context context) {
            super(context, DATABASE_NAME, null, 1);
            SQLiteDatabase db = this.getWritableDatabase();
        }
    
        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL(" CREATE TABLE " + TABLE_NAME + "(" +
                    COLUMN_PATIENT_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                    COLUMN_FNAME + " TEXT," +
                    COLUMN_LNAME + " TEXT," +
                    COLUMN_GENDER + " TEXT," +
                    COLUMN_USERNAME + " TEXT," +
                    COLUMN_PASSWORD + " TEXT," +
                    COLUMN_EMAIL + " TEXT," +
                    COLUMN_PNUM + " INTEGER," +
                    COLUMN_PADD + " TEXT," +
                    COLUMN_PROVINCE + " TEXT" +
                    ")"
            );
            db.execSQL(" CREATE TABLE " + TABLE_NAME1 + "(" +
                    COLUMN_DOCTOR_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                    COLUMN_FNAME1 + " TEXT," +
                    COLUMN_LNAME1 + " TEXT," +
                    COLUMN_GENDER1 + " TEXT," +
                    COLUMN_USERNAME1 + " TEXT," +
                    COLUMN_PASSWORD1 + " TEXT," +
                    COLUMN_EMAIL1 + " TEXT," +
                    COLUMN_PNUM1 + " INTEGER," +
                    COLUMN_PADD1 + " TEXT," +
                    COLUMN_PROVINCE1 + " TEXT," +
                    COLUMN_SPECIALITY + " TEXT" +
                    ")"
            );
            db.execSQL(" CREATE TABLE " + TABLE_NAME2 + " (" +
                    COLUMN_APPOINTMENT_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
                    COLUMN_PAT_ID + " INTEGER," + //<<<< NOT NULL ADVISABLE
                    COLUMN_DOC_ID + " INTEGER," + //<<<< NOt NULL ADVISABLE
                    COLUMN_BOOKING_DATE + " TEXT," +
                    COLUMN_BOOKING_TIME + " TEXT," +
                    "FOREIGN KEY (" + COLUMN_PAT_ID + ") REFERENCES " + TABLE_NAME + "(" + COLUMN_PATIENT_ID + "), " +
                    //"FOREIGN KEY (DOCTOR_ID,CATEGORY) REFERENCES TABLE_NAME1 (Doctor_ID,Speciality)ON DELETE CASCADE" +
                    "FOREIGN KEY (" + COLUMN_DOC_ID + ") REFERENCES " + TABLE_NAME1 + "(" + COLUMN_DOCTOR_ID + ") ON DELETE CASCADE" +
                    ")"
            );
            //db.setForeignKeyConstraintsEnabled(true); CANNOT SET HERE as onCreate is run within a transaction
        }
    
    
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            db.execSQL(" DROP TABLE IF EXISTS " + TABLE_NAME);
            db.execSQL(" DROP TABLE IF EXISTS " + TABLE_NAME1);
            db.execSQL(" DROP TABLE IF EXISTS " + TABLE_NAME2);
    
        }
    
        public boolean insertData(String name, String lname, String gender, String username, String password, String email,
                                  String pnum, String padd, String province) {
            SQLiteDatabase db = this.getWritableDatabase();
            ContentValues contentValues = new ContentValues();
            contentValues.put(COLUMN_FNAME, name);
            contentValues.put(COLUMN_LNAME, lname);
            contentValues.put(COLUMN_GENDER, gender);
            contentValues.put(COLUMN_USERNAME, username);
            contentValues.put(COLUMN_PASSWORD, password);
            contentValues.put(COLUMN_EMAIL, email);
            contentValues.put(COLUMN_PADD, padd);
            contentValues.put(COLUMN_PNUM, pnum);
            contentValues.put(COLUMN_PROVINCE, province);
            long rows = db.insertWithOnConflict(TABLE_NAME, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE);
            System.out.print(rows);
            Log.d("User_cannot_to_dupliate", "" + rows);
            long result0 = db.insert(TABLE_NAME, null, contentValues);
            if (result0 == -1)
                return false;
            else
                return true;
        }
    
        public boolean InsertData(String name1, String lname1, String gender1, String username1, String password1, String email1,
                                  String padd1, String province1, String pnum1, String speciality1) {
            SQLiteDatabase db = this.getWritableDatabase();
            ContentValues contentValues = new ContentValues();
            contentValues.put(COLUMN_FNAME1, name1);
            contentValues.put(COLUMN_LNAME1, lname1);
            contentValues.put(COLUMN_GENDER1, gender1);
            contentValues.put(COLUMN_USERNAME1, username1);
            contentValues.put(COLUMN_PASSWORD1, password1);
            contentValues.put(COLUMN_EMAIL1, email1);
            contentValues.put(COLUMN_PADD1, padd1);
            contentValues.put(COLUMN_PROVINCE1, province1);
            contentValues.put(COLUMN_PNUM1, pnum1);
            contentValues.put(COLUMN_SPECIALITY, speciality1);
            long rows = db.insertWithOnConflict(TABLE_NAME, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE);
            System.out.print(rows);
            Log.d("User_cannot_to_dupliate", "" + rows);
            long result = db.insert(TABLE_NAME1, null, contentValues);
            if (result == -1)
                return false;
            else
                return true;
        }
    
        public boolean UpdateData(String id, String name, String lname, String gender, String username, String password, String email,
                                  String pnum, String padd, String province) {
            SQLiteDatabase db = this.getWritableDatabase();
            ContentValues contentValues = new ContentValues();
            contentValues.put(COLUMN_PATIENT_ID, id);
            contentValues.put(COLUMN_FNAME, name);
            contentValues.put(COLUMN_LNAME, lname);
            contentValues.put(COLUMN_GENDER, gender);
            contentValues.put(COLUMN_USERNAME, username);
            contentValues.put(COLUMN_PASSWORD, password);
            contentValues.put(COLUMN_EMAIL, email);
            contentValues.put(COLUMN_PADD, padd);
            contentValues.put(COLUMN_PNUM, pnum);
            contentValues.put(COLUMN_PROVINCE, province);
            db.update(TABLE_NAME, contentValues, "ID= ?", new String[]{id});
            return true;
        }
    
        public boolean UpdataData1(String id1, String name1, String lname1, String gender1, String username1, String password1, String email1,
                                   String padd1, String province1, String pnum1, String speciality1) {
            SQLiteDatabase db = this.getWritableDatabase();
            ContentValues contentValues = new ContentValues();
            contentValues.put(COLUMN_DOCTOR_ID, id1);
            contentValues.put(COLUMN_FNAME1, name1);
            contentValues.put(COLUMN_LNAME1, lname1);
            contentValues.put(COLUMN_GENDER1, gender1);
            contentValues.put(COLUMN_USERNAME1, username1);
            contentValues.put(COLUMN_PASSWORD1, password1);
            contentValues.put(COLUMN_EMAIL1, email1);
            contentValues.put(COLUMN_PADD1, padd1);
            contentValues.put(COLUMN_PROVINCE1, province1);
            contentValues.put(COLUMN_PNUM1, pnum1);
            contentValues.put(COLUMN_SPECIALITY, speciality1);
            db.update(TABLE_NAME1, contentValues, "ID= ?", new String[]{id1});
            return true;
        }
    
        public Integer DeleteData(String id) {
            SQLiteDatabase db = this.getWritableDatabase();
            return db.delete(TABLE_NAME, "ID = ?", new String[]{id});
    
        }
    }
    

    Notes

    • I can see no need to incur the additional overheads of using AUTOINCREMENT just coding INTEGER PRIMARY KEY would ssuffice, so I'd suggest not using AUTOINCREMENT.
    • I have utilised CONSTANTS throughout for table and column names adding those that were omitted and amended some to adhere to a standard convention.
    • Some comments have been added
    • as the database will exist you will have to do one of the following before rerunning that App :-

      1. Delete/Clear the App's Data
      2. Uninstall the App
      3. Increase the Database version Number

    Testing

    The above code has been tested utilising the logDatabaseInfo from Are there any methods that assist with resolving common SQLite issues? .

    The resultant output being :-

    04-07 14:00:12.617 1471-1471/soanswers.soanswers D/SQLITE_CSU: Database Version = 1
        Table Name = android_metadata Created Using = CREATE TABLE android_metadata (locale TEXT)
        Table = android_metadata ColumnName = locale ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table Name = Patient_Reg_table Created Using = CREATE TABLE Patient_Reg_table(PatientID INTEGER PRIMARY KEY AUTOINCREMENT, FName TEXT,LName TEXT,Gender TEXT,Username TEXT,Password TEXT,Email TEXT,PNum INTEGER,Postal_Address TEXT,Province TEXT)
        Table = Patient_Reg_table ColumnName = PatientID ColumnType = INTEGER Default Value = null PRIMARY KEY SEQUENCE = 1
        Table = Patient_Reg_table ColumnName = FName ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Patient_Reg_table ColumnName = LName ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
    04-07 14:00:12.621 1471-1471/soanswers.soanswers D/SQLITE_CSU: Table = Patient_Reg_table ColumnName = Gender ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Patient_Reg_table ColumnName = Username ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Patient_Reg_table ColumnName = Password ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Patient_Reg_table ColumnName = Email ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Patient_Reg_table ColumnName = PNum ColumnType = INTEGER Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Patient_Reg_table ColumnName = Postal_Address ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Patient_Reg_table ColumnName = Province ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table Name = sqlite_sequence Created Using = CREATE TABLE sqlite_sequence(name,seq)
        Table = sqlite_sequence ColumnName = name ColumnType =  Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = sqlite_sequence ColumnName = seq ColumnType =  Default Value = null PRIMARY KEY SEQUENCE = 0
        Table Name = Doctor_Reg_table Created Using = CREATE TABLE Doctor_Reg_table(Doctor_ID INTEGER PRIMARY KEY AUTOINCREMENT, F_Name TEXT,L_Name TEXT,Sex TEXT,Username_Doc TEXT,Password_Doc TEXT,Email_Doc TEXT,PNum_Doc INTEGER,Postal_Address_Doc TEXT,Province_Doc TEXT,Speciality TEXT)
        Table = Doctor_Reg_table ColumnName = Doctor_ID ColumnType = INTEGER Default Value = null PRIMARY KEY SEQUENCE = 1
        Table = Doctor_Reg_table ColumnName = F_Name ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Doctor_Reg_table ColumnName = L_Name ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Doctor_Reg_table ColumnName = Sex ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Doctor_Reg_table ColumnName = Username_Doc ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Doctor_Reg_table ColumnName = Password_Doc ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Doctor_Reg_table ColumnName = Email_Doc ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Doctor_Reg_table ColumnName = PNum_Doc ColumnType = INTEGER Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Doctor_Reg_table ColumnName = Postal_Address_Doc ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Doctor_Reg_table ColumnName = Province_Doc ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Doctor_Reg_table ColumnName = Speciality ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
        Table Name = Appointment_table Created Using = CREATE TABLE Appointment_table (Appoint_ID INTEGER PRIMARY KEY AUTOINCREMENT,Pat_ID INTEGER,Doc_ID INTEGER,B_date TEXT,B_time TEXT,FOREIGN KEY (Pat_ID) REFERENCES Patient_Reg_table(PatientID), FOREIGN KEY (Doc_ID) REFERENCES Doctor_Reg_table(Doctor_ID) ON DELETE CASCADE)
        Table = Appointment_table ColumnName = Appoint_ID ColumnType = INTEGER Default Value = null PRIMARY KEY SEQUENCE = 1
        Table = Appointment_table ColumnName = Pat_ID ColumnType = INTEGER Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Appointment_table ColumnName = Doc_ID ColumnType = INTEGER Default Value = null PRIMARY KEY SEQUENCE = 0
        Table = Appointment_table ColumnName = B_date ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0
    04-07 14:00:12.625 1471-1471/soanswers.soanswers D/SQLITE_CSU: Table = Appointment_table ColumnName = B_time ColumnType = TEXT Default Value = null PRIMARY KEY SEQUENCE = 0