2
我想將匹配結果存儲在數據庫中。我有一個球員表,其中包含一個ID,名稱密碼。另一個存儲匹配的表格。然後最後一個匹配參與者表將有一個id
,player_id
(外鍵),match_id
(外鍵)和一個score
這是一個整數。我正在嘗試創建Match
表,以便它可以引用兩個Match參與者,但我不確定如何執行此操作。sqlite數據庫中的兩個表引用android
代碼我已經做了所有具有兩個鏈接到同一個表創建表
myDB.execSQL("CREATE TABLE IF NOT EXISTS "
+ playerTableName
+ " (Player_id integer primary key autoincrement, " +
"UserName VARCHAR, Password VARCHAR, Experience INTEGER, Rating INTEGER);");
myDB.execSQL("CREATE TABLE IF NOT EXISTS "
+ matchTableName
+ "(Match_id integer primary key autoincrement, " +
"? not sure here");");
myDB.execSQL("CREATE TABLE IF NOT EXISTS "
+ participantTableName
+ "(Participant_id integer primary key autoincrement, " +
"player_id INTEGER, match_id Integer," +
"FOREIGN KEY(player_id) REFERENCES "+ playerTableName+"(Player_id)," +
" FOREIGN KEY(match_id) REFERENCES "+ matchTableName+"(Match_id)," +
" Score INTEGER);");