@loganer
So… make a table that has inventory items, with each item having a foreign key linking back to the owner? And if you really need to distinguish between "no inventory" and "empty inventory" (i.e. no result rows" then just have a flag in the character table.
Something like (just writing this SQL from memory without testing):
CREATE TABLE characters (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL UNIQUE
);
CREATE TABLE inventory (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
owner INTEGER NOT NULL
REFERENCES characters (id)
);
-- Get a given character's inventory list:
SELECT id, name
FROM inventory_items
WHERE owner IN
(SELECT id
FROM characters
WHERE name = 'loganer');
Or I'd probably go even with like (creating a many-to-many)
CREATE TABLE characters (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL UNIQUE
);
CREATE TABLE items (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TABLE inventory_items (
character INTEGER NOT NULL
REFERENCES characters (id),
item INTEGER NOT NULL
REFERENCES items (id)
);
(probably with a lot more stuff ON DELETE CASCADE and indices and triggers and such, depending on the DBMS you're using)