I created two tables, WordsTable
and WordsDefenition
.
In the first table, WordId_id
is a foreign key to the second table. In the second table, three word definitions are stored for each word from the first table.
Here is how I inserted the data into both tables, what I want to ask is how do I fetch the data from both tables to display in list view?
import 'package:save_geez_learning_aid/SqlFlite_Database/DIctionery_word_model.dart';
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';
class SqlfdatabaseHelper{
Future<Database> initializeDB() async {
String path = await getDatabasesPath();
return openDatabase(
join(path, 'example.db'),
onCreate: (database, version) async {
await database.execute(
"CREATE TABLE WordsTable("
"WordId_id INTEGER PRIMARY KEY AUTOINCREMENT, "
"Column_word TEXT NOT NULL,"
"Column_Languages Text NOT NULL,"
")",
);
await database.execute(
"INSERT INTO WordsTable ('WordId_id', 'Column_word', 'Column_Languages')values (1, 'ዘመድ', 'amharic')",
);
await database.execute(
"CREATE TABLE WordsDefenition("
"WordId_id int FOREIGN KEY REFERENCES WordsTable(WordId_id),"
"Column_word_geez TEXT NOT NULL,"
"Column_word_oromoo TEXT NOT NULL,"
"Column_word_amharic TEXT NOT NULL,"
"Column_word_english TEXT NOT NULL,"
")",
);
await database.execute(
"INSERT INTO WordsDefenition ('WordId_id', 'Column_word_geez', 'Column_word_oromoo ','Column_word_amharic','Column_word_amharic')values (1, 'fira', 'fira', 'familly')",
);
},
version: 1,
);
}
}