外键约束实现失败Android Sqlite

时间:2018-04-07 08:28:10

标签: android sqlite foreign-keys create-table

当我运行应用程序时,没有正在创建表。我试图打开外键属性的实现,但它没有工作。如果有另一种方法可以做到这将非常有帮助。这是项目的所有代码我试图做一个患者预约调度系统。所以我试图在我的任命表中实现外键,你可以看到下面。   的 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});

}

}

1 个答案:

答案 0 :(得分:2)

首先有一些问题与FOREIGN KEY有关。您说该约束应该适用于 PATIENT_ID 列,但尚未在 Appointment_table 中定义此类列。

logcat会包含一个堆栈跟踪,说明 PATIENT_ID 列不存在。

修复这会导致错误,指出 TABLE_NAME 不存在,因为您在引号中包含了 TABLE_NAME ,因此字面意思是这样。

第二个FOREIGN键有类似的错误。然而,当您尝试使用a时,复合似乎是一个不必要的COMPOSITE FOREIGN KEY。 DOCTOR_ID CATEGORY 列均未定义, TABLE_NAME1 被视为文字,因为它包含在引号内。由于 Doctor_Reg_table 中的 DOCTOR_ID 唯一标识关系,因此不需要复合列(CATEGORY和SPECIALTY)。此外,包括CATEGORY / SPECIALTY会有问题,因为不能满足FOREIGN KEYS的索引要求。

最后,您无法使用setForeignKeyConstraintsEnabled(true)中的onCreate,因为它在一个事务中运行。您可以覆盖onConFigure方法: -

  •   在API级别16中添加的

    onConfigure void onConfigure(SQLiteDatabase db)   在配置数据库连接时调用,以启用   诸如预写日志记录或外键支持等功能。

         

    在onCreate(SQLiteDatabase)之前调用此方法,   onUpgrade(SQLiteDatabase,int,int),onDowngrade(SQLiteDatabase,int,   调用int)或onOpen(SQLiteDatabase)。它不应该修改   数据库除了根据需要配置数据库连接。

         

    此方法应仅调用配置参数的方法   数据库连接,例如enableWriteAheadLogging()    setForeignKeyConstraintsEnabled(boolean),setLocale(Locale),   setMaximumSize(long),或执行PRAGMA语句。 onConfigure

以下代码有效,可能是您想要的: -

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});

    }
}

备注

  • 我认为没有必要承担使用AUTOINCREMENT只需编码INTEGER PRIMARY KEY的额外费用,因此我建议不要使用AUTOINCREMENT
  • 我已经在表格和列名中使用了CONSTANTS,添加了省略的内容并修改了一些以符合标准惯例。
  • 添加了一些评论
  • 由于数据库存在,您必须在重新运行该应用程序之前执行以下一次: -

    1. 删除/清除应用程序的数据
    2. 卸载应用
    3. 增加数据库版本号

测试

上述代码已使用Are there any methods that assist with resolving common SQLite issues? 中的 logDatabaseInfo 进行了测试。

结果输出为: -

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