コード例 #1
0
        public async Task Create()
        {
            command.Parameters.Clear();
            command.CommandText = "PRAGMA foreign_keys = ON;" +
                                  "CREATE TABLE IF NOT EXISTS Users " +
                                  "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
                                  "name TEXT NOT NULL, " +
                                  "surname TEXT NOT NULL, " +
                                  "login TEXT NOT NULL, " +
                                  "pswd TEXT NOT NULL);" +
                                  "CREATE TABLE IF NOT EXISTS Coaches " +
                                  "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
                                  "usr_id INTEGER NOT NULL," +
                                  "FOREIGN KEY(usr_id) REFERENCES Users(id) ON DELETE CASCADE);";
            command.CommandType = CommandType.Text;
            await db.ExecuteNonQueryAsyncAtomic(command);

            Debug.WriteLine("DB Created");
        }
コード例 #2
0
        public async Task Create()
        {
            command.Parameters.Clear();
            command.CommandText = "PRAGMA foreign_keys = ON;" +
                                  "CREATE TABLE IF NOT EXISTS Trainings " +
                                  "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
                                  "name TEXT NOT NULL, " +
                                  "coach_id INTEGER NOT NULL, " +
                                  "date INTEGER UNIQUE NOT NULL);" +
                                  "CREATE TABLE IF NOT EXISTS Trainees " +
                                  "(training_id INTEGER NOT NULL," +
                                  "user_id INTEGER NOT NULL," +
                                  "PRIMARY KEY(training_id, user_id));";
            command.CommandType = CommandType.Text;
            await db.ExecuteNonQueryAsyncAtomic(command);

            Debug.WriteLine("DB Created");
        }