Could someone please show me how to create a foreign key relationship between two tables in Godot. I can not figure based on the current documentation.
extends Node2D
const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns")
var save_path = "user://data.sqlite"
var db
func _ready():
db = SQLite.new()
db.path = save_path
db.foreign_keys = true
db.open_db()
db.create_table("dog_names", {
"id": {"data_type": "int", "primary_key": true, "auto_increment": true},
"first_name": {"data_type": "text"},
"last_name": {"data_type": "text"},
})
db.create_table("owners", {
"id": {"data_type": "int", "primary_key": true, "auto_increment": true},
"name": {"data_type": "text"}
})
db.query("SELECT * FROM dog_names;")
print(db.query_result[0]["first_name"])
Essentially I just want to add a many-to-one relationship between table owner and table dog. One owner can have many dogs but a dog can only have one owner.
Thanks