create table object_types (
id integer primary key not null,
name unique text not null
);
insert into object_types(id, name) values (1, 'player');
insert into object_types(id, name) values (2, 'weapon');
insert into object_types(id, name) values (3, 'armor');
insert into object_types(id, name) values (4, 'misc');
create table uuids (
uuid text primary key not null
);
create table players (
uuid text unique not null references uuids(uuid),
name text unique not null
);
create table weapons (
uuid text unique not null references uuids(uuid),
name text unique not null
);
create table armors (
uuid text unique not null references uuids(uuid),
name text unique not null
);
create table misc_objects (
uuid text unique not null references uuids(uuid),
name text unique not null
);
create table player_inventories (
player_uuid integer not null references players(uuid),
object_type_id integer not null references object_types(id),
object_uuid integer not null references uuids(uuid)
);
insert into player_inventories(player_uuid, object_type_id, object_uuid) values ('uuid-with-dashes-1', 2, 'uuid-with-dashes-21');
insert into player_inventories(player_uuid, object_type_id, object_uuid) values ('uuid-with-dashes-1', 3, 'uuid-with-dashes-37');
insert into player_inventories(player_uuid, object_type_id, object_uuid) values ('uuid-with-dashes-1', 4, 'uuid-with-dashes-117');
Could you explain that a little more? I'm pretty inexperienced with RDBs so I'm probably missing something. It seems like if you have objects in memory,
Obj1
Components: comp1, comp2
Obj2
Components: comp2, comp3
And you have DB tables
Component1
Obj1 dataA dataB dataC
Component2
Obj1 dataA dataB dataC
Obj2 dataA dataB dataC
Component3
Obj2 dataA dataB dataC
Then it looks straightforward to load the correct components to objects.