I’m fairly new to SQL/SQLite and am making a database for storing highscores/power/misc other objects. This is how it’s set up (it’s a little more complicated but this pertains to the question).
TABLE Worlds (0-4)
-world_id:Int
TABLE Levels (0-8)
-level_id:Int
TABLE GameRecord
-record_id:Int
-world_id:FK
-level_id:FK
-highscore:Int
-locked:Bool
My first two tables (Worlds and Levels) only have one key in their table (id). Is this the proper way to setup a database schema? It’s in Android and SQLite, but I don’t think that affects anything. Thanks for your help!
This is a fine way to set up a database schema if you plan to expand the
WorldsandLevelstables to include more fields later. Things like a name, or other metadata, would be good to put there.If your worlds and levels are merely numbers and nothing else, you can just use integers in your
GameRecordworld_idandlevel_idfields without worrying about the foreign key relationship. You could also just start this way (without the other tables) and then change those columns to be (or be treated like) foreign keys to the other tables in the future, when you have actual data to put there.