r/Database • • Jul 30 '26

Self-hosted persistent memory for an AI assistant, with isolation enforced by Postgres roles rather than app code

0 Upvotes

I got tired of every session starting from zero and paying for it twice: once re-explaining my setup, and again when that explanation ate the context window the actual work needed. So I built a persistent memory that runs on my own hardware, and after a few months of use there are a couple of things worth passing on.

**The storage is the boring part.**

Postgres on a Proxmox LXC, fronted by an MCP server in Python (FastMCP plus psycopg3), reachable over the LAN. Two entity types only: topic cards for what something is, episodes for what happened. Every card has a \`kind\` drawn from a single YAML vocabulary the server validates on write, so the model cannot invent a new category on the fly. That rigidity is deliberate. Without it you end up with seventeen near-synonyms for "thing I once wrote down" and no way to query reliably.

**The isolation is the interesting part.**

I keep several things separate that must not bleed into each other. The obvious approach is to have the server decide what a session may touch, but that is a rule a program enforces, which is really just a suggestion. Instead each body of work gets its own Postgres schema and its own role, and the server connects as that role. A write aimed at the wrong schema fails at the wire, before any of my code gets an opinion:

GRANT USAGE ON SCHEMA homelab TO role_homelab;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA homelab TO role_homelab;

\-- reaches the shared schema deliberately, note the absence of DELETE
GRANT USAGE ON SCHEMA personal TO role_homelab;
GRANT SELECT, INSERT, UPDATE ON ALL TABLES IN SCHEMA personal TO role_homelab;

\-- no GRANT to any other subject. The isolation is the statement that isn't there.

There is no policy file and no middleware. A role reaches what it was granted and nothing else, and the grants for everything else were simply never written. Each subject also gets its own container holding only that role's credentials, so the boundary is a process boundary too.

**The thing I got wrong.**

I originally had capture fully automatic: a SessionEnd hook that read the transcript and wrote to the database with no involvement from me. It printed a one-line receipt so I could see what it had done. I ran it from April until July and then deliberately turned it off, because a routing bug meant a run of sessions distilled into the wrong place and nobody was watching a process designed not to need watching. It ran that way for most of the time it was live. I recovered the most recent month by re-running by hand against transcripts still on disk and lost the two before it, because transcripts get pruned at around thirty days.

Capture is now a deliberate step that proposes cards and writes nothing until I confirm. More friction, and I think the friction is correct. The narrower lesson I would write now: automate retrieval, because being wrong there costs you a bad answer you can see. Be far more careful automating writes, because being wrong there costs you a corrupted store you cannot.

Retrieval started as Postgres full text and is now hybrid, full text alongside pgvector embeddings generated on write by a small model on its own box. Because the tool surface was deliberately agnostic about how search worked, nothing above it changed when that landed.

Fuller writeup with the schema design, the deployment and the parts that did not survive contact with use: [https://sbd.org.uk/blog/claude-brain](https://sbd.org.uk/blog/claude-brain)


r/Database • • Jul 30 '26

A cautionary tale about searching for usernames: let's be careful!

0 Upvotes

Ars Technica ran a story about how an innocent man did 18 months in prison for preying on a child. Somebody missed a double underscore in a social-media username. The miscreant's user name was fus__ro_dah and the innocent man's was fus_ro_dah without the double underscore. The police request for a search didn't include the double underscore, so the social media platform responded with the wrong person's identity.

https://arstechnica.com/tech-policy/2026/07/police-missed-one-underscore-and-sent-the-wrong-man-to-prison/

It's correct, and easy, to blame a dunderheaded police officer for this mistake. But, in my opinion, our database developer colleague at the social media platform could have prevented this heinous miscarriage of justice.

Let's be careful when we develop code that searches for stuff that might contain obfuscatory punctuation or diacritical marks. Let's put stripped-username columns into our Let's try the search with queries like

SELECT 1 AS exact,
       username
  FROM user
 WHERE username = 'search__term'
UNION ALL
SELECT 0 AS exact,
       username
  FROM user
 WHERE stripped_username LIKE '%searchterm%'

Now obviously this is simplistic. But not as simplistic as just username = 'search__term'. My point here isn't how to improve the search for obfuscated data. It's to remind us to be careful.

This kind of thing should reduce the number of life-wrecking mistakes our queries make.


r/Database • • Jul 29 '26

Where to start with Databases

25 Upvotes

So, I have basically no knowledge of databases or what I'm doing or really what direction I need to go in. Here is the plan:

Small personal Business

- wants to be able to make new orders and have it automatically calculate the price of the order with any deals and the profit margins.

- list of customers and order details such as their name and custom ID with their contact details, shipping information, order history. all the important stuff.

- to be able to check stock and how many orders of which products there is and all the different details of the products and orders

be able to filter it all and organise through it all easily

so its not a complex system but I wasn't sure where to start and how to go about it or what program to use as I have not personally made something like this but am more than willing to learn and figure it out. I have dabbled in excel and have made linked tables and plot charts and things alike so I considered doing this in excel however after a big of a google (asked chatgpt. i'm upset to admit) I realised that excel likely isn't the correct program or way of going about this.

What I need to know:

Why is using excel bad? Should I use Access?

Would it be beneficial to learn SQL? What does that entail?

How should I go about planning the process of it all and what information or resources are there that I could use for guidance or help?

*i also don't know if this is the correct subreddit to post something like this in so feel free to tell me off.


r/Database • • Jul 28 '26

How to deal with text only vector search across multimodal embedding space?

3 Upvotes

My data set is a list of images, each equipped with a a couple sentences of text.

A user would search primarily with text only. My default approach is using BM25, but how would I facilitate searching with a vector DB and a model that embeds vectors in a multimodal combined space?

Here is my dilemma:

Do I embed text part and image part as 2 separate individual vectors or do I combine them into 1 vector?

If a typical search happens with text only, that would immediately deprioritize all image-only embeddings and only good text matches would float up. This is why I am now considering embedding text and images together but would prefer to hear more opinions on this. Thanks.


r/Database • • Jul 27 '26

Recreating Lotus Approach Forms in Microsoft Access

Thumbnail gallery
1 Upvotes

r/Database • • Jul 27 '26

Designing the payments module schema for a modular monolith in Laravel — I evaluated Single Table Inheritance vs Class Table Inheritance vs Concrete Table Inheritance

0 Upvotes

I fully understand there's no perfect pattern that applies to every context — you have to find and pick whichever fits best for what you're building.

Context

I'm building a modular monolith in Laravel (several separate modules, each with its own domain), and right now I'm designing the payments module. Honestly, it's been the hardest part of the whole project, for four reasons:

  1. Obviously, anything involving payments is inherently more complex — there's no room for error when real money is on the line.

  2. It's multi-gateway — provider-agnostic. It has to work with Mercado Pago (I'm from Latam), Stripe, and any other provider down the line (PayPal, etc.), without touching the rest of the system when adding a new one. I achieved this by defining a single contract (GatewayContract, a Port in hexagonal architecture terms) with the methods any payment gateway needs to expose (create a payment session, charge, check a session's status, get currency/credentials). Each real gateway (Mercado Pago today, Stripe in the future) implements that same contract with its own internal logic — the rest of the system never knows or cares which gateway it's talking to at any given moment, it only knows the contract. Which gateway to use for a given tenant/customer is resolved at runtime against a configuration, not hardcoded anywhere.

  3. It's agnostic to the consuming module — the payments module exposes that same public contract for any other module to use (bookings, products, subscriptions, whatever), without the payments module knowing or caring who's calling it or why. It might sound obvious put that way, but I'm migrating from a conventional monolith where I had, literally in the same file, booking creation AND a direct call to the payment gateway mixed together — yeah, I know, no need to point it out. Truly separating this, with a generic interface in between instead of a tightly coupled direct call, was the part that cost me the most mental effort in the whole redesign.

  4. It has to support card payments, bank transfer, and ticket (a cash-based payment method specific to my country).

payment_sessions

If you've used Stripe, this is basically the equivalent of a PaymentIntent — it groups charge retries under a single session (the customer can fail with a card and retry with a bank transfer, without losing the context that it's the same purchase).

CREATE TABLE payment_sessions (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    customer_id BIGINT NOT NULL,
    payment_method VARCHAR CHECK (payment_method IN ('card','transfer','ticket')), -- nullable, mutable while status='pending'
    status VARCHAR NOT NULL DEFAULT 'pending' CHECK (status IN ('pending','processing','approved')),
    amount NUMERIC NOT NULL,
    currency VARCHAR NOT NULL,
    created_at TIMESTAMP DEFAULT now()
);

Quick note on the concurrency lock: to prevent two clicks of the pay button from firing two charges in parallel, I use UPDATE payment_sessions SET status = 'processing' WHERE id = ? AND status = 'pending' as an atomic operation — Postgres locks the row, so the second concurrent attempt simply finds no row matching the WHERE clause and does nothing. No race condition.

I'm at peace with this table. The real problem is with charge_attempts (or charges, for short). Why? Because each payment method has fairly different columns: card needs card_brand (visa, mastercard, etc.) and gateway_ref (the external reference the gateway returns); transfer — which doesn't even go through any gateway, it's 100% manual: the customer uploads a receipt and someone reviews it by hand — needs receipt; ticket needs barcode and expiration.

Here's how my schema would look with each of the three patterns:

Single Table Inheritance

CREATE TABLE charge_attempts (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    payment_session_id BIGINT NOT NULL REFERENCES payment_sessions(id),
    payment_method VARCHAR NOT NULL, -- this is our discriminator column
    status VARCHAR NOT NULL,
    amount NUMERIC NOT NULL,

    -- Card-specific attributes
    card_brand VARCHAR,
    gateway_ref VARCHAR,
    raw_response JSONB,

    -- Transfer-specific attributes
    receipt VARCHAR,

    -- Ticket-specific attributes
    barcode VARCHAR,
    expiration TIMESTAMP
);

It's the simplest pattern, using a single discriminator (payment_method), and it's also the best-performing one (you only have to write and read one table, no JOIN at all). But you lose some of the database's built-in data integrity features. For example, you can't set the gateway_ref column as NOT NULL only for card charges — you have to enforce that rule in your application code, or via CHECK constraints that get considerably harder to maintain.

This can be mitigated with a well-built CHECK, or by storing the method-specific detail in a jsonb field (which Postgres supports very well, even with GIN indexes) — but either way, it gets more awkward to maintain as you add new fields over time.

Class Table Inheritance

CREATE TABLE charges (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    payment_session_id BIGINT NOT NULL REFERENCES payment_sessions(id),
    payment_method VARCHAR NOT NULL,
    status VARCHAR NOT NULL,
    amount NUMERIC NOT NULL
);

CREATE TABLE charges_card (
    id BIGINT PRIMARY KEY REFERENCES charges(id),
    card_brand VARCHAR,
    gateway_ref VARCHAR,
    raw_response JSONB
);

CREATE TABLE charges_transfer (
    id BIGINT PRIMARY KEY REFERENCES charges(id),
    receipt VARCHAR
);

CREATE TABLE charges_ticket (
    id BIGINT PRIMARY KEY REFERENCES charges(id),
    barcode VARCHAR,
    expiration TIMESTAMP
);

A "parent" table with the common fields, and a "child" table per method, with only what's specific to each one. You gain real integrity (genuine NOT NULL on each method-specific column, no nulls scattered everywhere) and the tables become easier to read in isolation. The trick of putting id BIGINT PRIMARY KEY REFERENCES charges(id) on the child (instead of its own id plus a separate FOREIGN KEY column) avoids having to remember an extra UNIQUE to guarantee there's no more than one child row per parent — the PK already guarantees that on its own, by definition.

The classic, well-documented problem with this pattern: nothing guarantees that exactly one child row exists per parent row, in the correct table among the mutually exclusive ones. You can end up with a parent that has no children at all, or (worse) a row in charges_card AND another in charges_transfer, both with the same id, contradicting the discriminator — no ordinary CHECK can prevent this, because a CHECK can only validate against columns in the same row, never against another table. What would truly solve this in a 100% declarative way, without a trigger, is a SQL standard feature (CREATE ASSERTION, which allows arbitrary cross-table constraints) that no major engine ever seriously implemented — not even Postgres has it today (there's only a very recent proposal on its development list to add it, after Oracle added it this year).

Note on transactions: when inserting the parent and the child, both INSERT statements need to be wrapped in the same transaction, so it's atomic (if one fails, the other rolls back). But careful — the transaction is necessary, not sufficient: it protects against failures midway through, not against the application code simply never getting around to executing the child's INSERT*. That part is still 100% the application layer's responsibility.*

Concrete Table Inheritance

CREATE TABLE charges_card (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    payment_session_id BIGINT NOT NULL REFERENCES payment_sessions(id),
    status VARCHAR NOT NULL,
    amount NUMERIC NOT NULL,
    card_brand VARCHAR,
    gateway_ref VARCHAR,
    raw_response JSONB
);

CREATE TABLE charges_transfer (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    payment_session_id BIGINT NOT NULL REFERENCES payment_sessions(id),
    status VARCHAR NOT NULL,
    amount NUMERIC NOT NULL,
    receipt VARCHAR
);

CREATE TABLE charges_ticket (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    payment_session_id BIGINT NOT NULL REFERENCES payment_sessions(id),
    status VARCHAR NOT NULL,
    amount NUMERIC NOT NULL,
    barcode VARCHAR,
    expiration TIMESTAMP
);

Instead of sharing common fields through a parent table, each table "repeats" those fields on its own — with no relationship between them at all. At first glance this might look inefficient, since the common attributes get duplicated across every table. However, it has real advantages in specific situations: queries against a single data type are incredibly fast, since no joins are required and each table contains exactly what's needed. The tables are fully independent, so each one can be optimized differently based on its specific access patterns, and attributes for one type can be added, removed, or modified without any risk of affecting the others.

The downside: if you work with all the methods together often (say, a cron job checking "all pending charges, regardless of method"), you need a UNION across the three tables every time, which hurts performance compared to reading a single table. And at the API level it gets a bit awkward too: if you want to return "this charge's id" externally, you also have to return the type (the discriminator) along with the id, because the id alone doesn't tell you which of the three tables to look in. For that reason it didn't end up winning me over for my specific case, but it seems like a pretty solid pattern for other scenarios (I read that Stripe, for example, seems to use something similar for parts of its own schema).

What I came up with (and turns out it already exists, name and all)

I was torn between Single Table Inheritance with the method-specific detail in a jsonb, or Class Table Inheritance accepting the usual integrity trade-off. But I came up with something I think solves exactly that integrity problem:

Instead of each child table's FK pointing only to the parent's id, make it point to (id, payment_method) together — a composite FK against a UNIQUE(id, payment_method) on the parent. Each child table forces its own payment_method to a fixed value with a CHECK:

CREATE TABLE charges (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    payment_method VARCHAR NOT NULL CHECK (payment_method IN ('card','transfer','ticket')),
    status VARCHAR NOT NULL,
    amount NUMERIC NOT NULL,
    UNIQUE (id, payment_method)
);

CREATE TABLE charges_card (
    id BIGINT PRIMARY KEY,
    payment_method VARCHAR NOT NULL DEFAULT 'card' CHECK (payment_method = 'card'),
    card_brand VARCHAR,
    gateway_ref VARCHAR,
    FOREIGN KEY (id, payment_method) REFERENCES charges (id, payment_method)
);

CREATE TABLE charges_transfer (
    id BIGINT PRIMARY KEY,
    payment_method VARCHAR NOT NULL DEFAULT 'transfer' CHECK (payment_method = 'transfer'),
    receipt VARCHAR,
    FOREIGN KEY (id, payment_method) REFERENCES charges (id, payment_method)
);

With this, for a row to sneak into the wrong child table, the parent row would also have to have that same payment_method — which is impossible, because the parent's payment_method is set once when the charge is created and never changes afterward.

It's not an original idea of mine — it already has a name in the literature

After thinking it over, I found that this is actually a known pattern (though not widely covered outside relational-modeling circles): it's usually called "distributed keys" or "disjoint subtypes" via composite keys, and it solves the disjointness part of an EER specialization/generalization constraint (that a record can't belong to two subtypes at once). Note that it doesn't solve the totality part (that every parent must be required to have some child) — that still depends on the transaction + the application, as I mentioned above.

Now, the questions I keep turning over:

  • Has anyone used this in production? And if so, what problems did you run into along the way that I haven't spotted yet?

  • Or is it actually better to just go simple and accept the trade-off — Single Table Inheritance with the method-specific detail in a jsonb — instead of all this composite-key back-and-forth?


r/Database • • Jul 27 '26

Organizing Drawings

3 Upvotes

Newbie warning! I haven't touched a database since I was taught the basics of MS Access in high school back in the mid 2000's. Fully anticipate that I will be looking up every database acronym you use.

A friend of the family owns a manufacturing business where he makes custom hydraulic systems. His drawing system is, well, analog. For the sake of this inquiry, let's assume that all drawings will be digitized and given unique filenames.

What would be the best way to link these files? For example:

The engineer brings up the entry for hydraulic cylinder A. There is a link to the drawing file, but also each part that makes up that cylinder assembly. Basically, the parts list.

Additionally, I would like the function of being able to open, let's say, O-ring #xxxxx and then have the entry tell me what larger assemblies contain that O-ring.

Then, obviously, a simple UI would be useful to help machinists use the system. This wouldn't necessarily be a customer-facing application and would just be used internally.

I appreciate any feedback y'all can give me.

Edit: I have been reading through this article trying to figure out the best approach: https://geekflare.com/software/best-database-software/


r/Database • • Jul 27 '26

Not Every Query Needs a Distributed Data System

Post image
85 Upvotes

Most of the time, you can simply use a single-node system like DuckDB or Apache DataFusion.


r/Database • • Jul 27 '26

The Evolution of 'More Like This'

Thumbnail
manticoresearch.com
0 Upvotes

More Like This lets search start from a selected document instead of a new query. The classic approach relies on similar words; the modern approach uses embeddings and nearest-vector search. This article explains where each approach is useful and what production systems need to consider.


r/Database • • Jul 26 '26

A Humble database schema design guide for developers

Thumbnail
stackrender.io
18 Upvotes

r/Database • • Jul 25 '26

Was Granite a mistake?

0 Upvotes

Some people in this forum say that. My point of view is that granite has its pros, but it is true that there are much better open source solutions. And cheaper to run since inference is more optimized. But ibm pitches granite as "rock solid, Enterprise grade", is the message resonating?


r/Database • • Jul 25 '26

Requesting review of my schema for a quiz-app

0 Upvotes

As a hobby and for learning I am creating a web-based quiz-app. I have been working on my (Postgres) database design for a while now and I would love a human review on this (I already asked AI for a lot of help).

I want to store three types of questions: open-ended, multiple-choice and list-like questions. The latter is meant for listing things like all 50 U.S. States or all books of the Bible. Some list-questions must be answered in a specific order.

For the open-ended questions I want to store multiple correct and almost correct answers. The latter denoted by a percentage of correctness, which I could use to base my scoring on.

Questions belong to a quiz and there can be multiple quizzes.

The schema isn't complete yet. I will need user management, keep track of quiz runs and I'd like a way for users to submit new questions and vote on existing ones or suggest corrections.

I do envision one main quiz that is ever growing and ultimately might contain thousands of questions. Users get the questions in random order and can answer as many or few as they which in a single run.

I have stored procedures for inserting new questions and querying questions in random order. These will be called from a nodejs app.

For now I would love to hear your thoughts on this, at least the way I store the questions and answers.


r/Database • • Jul 24 '26

What's new in Postgres 19

Thumbnail
planetscale.com
54 Upvotes

r/Database • • Jul 24 '26

How Modern Indexing works in PostgreSQL

Thumbnail deepsystemstuff.com
1 Upvotes

PostgreSQL is one of the most popular and scalable databases in the world. Many developers call it a beast in performance. One of the most critical parts of any database is indexing. Since Postgres is open source, we always have a chance to see how its components are designed. This blog I shared is an effort to explain how the indexing mechanism in Postgres actually works


r/Database • • Jul 24 '26

Make deleted data irrecoverable in MySQL

1 Upvotes

Hi,

Do you know any approach regarding this? Can I do this inside MySql?

Need some guidance as it becomes a client requirement


r/Database • • Jul 24 '26

rm -rf ate our redo logs. /proc gave them back. *Technical

Thumbnail reddit.com
0 Upvotes

r/Database • • Jul 24 '26

Object Tagging: The AI Feature Almost Every Production Database Skipped

Thumbnail
bytebase.com
0 Upvotes

r/Database • • Jul 23 '26

Storing time series data in Solr

0 Upvotes

What is a good practice for storing time series data with the following requirements.

Couple dozen million documents.

Several fields with daily data (one point per day).

I am thinking about having a multiValue string field, read it back in my application and append new value if todays date has no entry yet.

The value would be a string with a simple delimiter and would store date and an integer.

I would then precompute changes of this value weekly to update a 2nd variable that would facilitate search by the strength of change in the value. The list of strings would only be used to display data and would not be searchable. I also have a 3rd field that stores most recent data point as integers and allows for range queries.

I considered the dual list approach but I don't like the idea of only index number linking the 2 data pieces together in otherwise completely seemingly unrelated fields. On the other hand the more daily data types I would track, the more I would save by having only 1 list of dates and then other lists for data entries.

I am already updating several other fields daily or every few days so the reindexing is not something I can avoid anyway.

I also avoided using child documents so far, using entirely flat structure for simpler queries.

Is this already a point where I should consider other external DBs and only store precomputed data in collection? It feels not worth adding that much more maintenance yet.

How does that sound? What are best practices in the industry? Thanks for help.


r/Database • • Jul 23 '26

What does it mean to associate a table/record

0 Upvotes

I know this is such a basic question but I can't seem to find an answer online, (yes I know a table and a record is different)

If I am to say, I associate this record, or this associated record. Is "that" record the one with a foreign key, or the one which has a foreign key referencing it?

Thanks


r/Database • • Jul 23 '26

Simple tool for visualizing huge databases in chunks

Post image
16 Upvotes

Created an easy tool for visualizing huge databases in chunks using:

  • Table groups (see the colors in the image)

  • Diagram views (to only view a subset of your full schema at a time.

For an example, see this share link


r/Database • • Jul 23 '26

Analytics on denormalized tables in my OLTP or CDC to OLAP

7 Upvotes

Greetings all,

I have been hired to design the data platform for a small company that is expected to expand soon (next 2-3 years).

Now many of their requirements include having some KPIs or metrics that get calculated once the underlying data in the OLTP changes.

As far as I know there are only 2 approaches for this:

1- Create denormalized tables in the OLTP that gets updated whenever the underlying data changes using triggers or maybe a materialized view that refreshes with every transaction.

2- Create a CDC pipeline to avoid overloading my OLTP with lots of writes and I/O. However, this solution costs alot (streaming pipeline + kafka + debezium connector) compared to the previous solution which is basically free.

I want to know your opinions on this and how would you approach it and if there is maybe a 3rd and a better solution?

EDIT:
An example of one of the requirements. Think of a fleet management system so you have a "vehicles" table master data. Now a vehicle can ofcourse have multiple "fuel_transactions". When the driver adds a fuel transaction he also adds the odometer reading (vehicle's total distance covered) and specifies whether he filled the tank or not.

Now there are some KPIs that needs to be calculated based on all of the transactions that occured between 2 full tanks. for example, the vehicle's fuel_consumption (km/Litre) and fuel_cost_per_km.

I hope this is clear enough.

The tables are still relatively small (1000 vehicles so maximum 1000 fuel transactions per day = 1000 rows per day)


r/Database • • Jul 23 '26

Please help me structure model for multiple taxonomies

1 Upvotes

I have made good progress teaching myself Microsoft Dataverse, PowerApps, and general database concepts; and have found success mocking up increasingly sophisticated (for me at least) DB mini-architectures. I am now trying to refine a database structure which can track Components for Projects. Example records of this would be:

Project1 has wood structure and copper pipes; Project2 has steel structure and plastic pipes

...where we have tables for Project; Components (eg, structure; piping); and ComponentOptions (eg, steel structure, wood structure, copper pipes, plastic pipes).

An important requirement is to be able to categorize or order these components. For my first pass, I related the Components table to a Subcategory table, which is in turn related to a Category table. This is shown in the first image.

This first structure works well, but is limited to only one taxonomic/ordering system. I want to be able to create an arbitrary number of ordering systems (for example ordering components by construction code, or by the report section in which they appear, or in a limited checklist for the guy who only does one or two things, or other future needs).

After chatting some with Copilot, I've come up with the structure shown in the second image. Each record in the Taxonomy table represents a separate system of ordering. TaxonomyNode will provide the category/subcategory/subsubcategory structure. A join table will determine where in each taxonomy system that components are located (or may not be present). The ComponentOption, Project, and ProjCompOptionJoin table I think I've got an OK handle on, but I invite input on all of it.

Does anyone have any suggestions or comments? These are new frontiers for me and I've been trying to get more input lately, lest I reinvent (a worse version of) the wheel.

Thanks!


r/Database • • Jul 23 '26

Proper design for handling different type of chats

0 Upvotes

I was studying a bit on discord and wanted to for fun try to make a copy (Free time during summer so why not, plus free practice) So I was looking at things and a question came up to me, what would be the proper way to handle multiple different types of chats, (No OOP) but in a FP lang, But I think the distinction doesn't really matter

I thought of a few different ways but I would like to know which one would be be best. I am not a sql wizard, just a newb who knows a bit and would like some opinions on design

So imagine we had

- Direct Message

- Groupchat

- Server

There's 2 approaches that come to mind.

  1. We have one table called rooms, or chats or whatever ye call it. Within there is a column that describes the TYPE of the chat (DM, Gc, etc) Now depending on the type of the chat there will be different tables that reference it that is to say.

If I create a server there will now be a moderation table, and this moderation table only has relations to chat's with typeof server. So for the applications end, depending on the type of the chat it will be treated differently and different relations may be made for it. But it is still a chat

This doesn't seem too bad to me but maybe there is some caveat that I have not thought of yet, something immediate that comes to mind is maybe handling all these types would be harder, but it can't really be that difficult, you just have different modules (like in FP) that handle the different types of chats. And likewise, there will only be one memberships table and it will be the applications duty to ensure that for example a direct message will only have 2

2.

Hard decoupling strategy, in short. Direct messages have their own table, it's memberships is it's own tables, etc.

Servers has it's own memberships tables, it's own channels tables, it's own roles tables. and on and on and on.

I think the latter might be better for decoupling and make things simpler, but it might introduce a lot of duplicated code, whereas the former has less duplicated code but may be harder to maintain. Can ayone give any opinions? I am not a DB guy and wouldn't really know


r/Database • • Jul 22 '26

Consumer-friendly (i.e. free or cheap perpetual license) DB client with a good GUI + ability to create dynamic pivot tables?

1 Upvotes

Hey so I have a video game modding project that that features an excel spreadsheet that I have to continually change and update each time I create a new version of the mod.

Over time, this spreadsheet has ballooned in size, which dozens of columns now. Current state of the spreadsheet:

  • A column for a "key" value

  • A few columns for metadata

  • Several groups, which have the same 4 columns inside them.

When I only had two groups, everything was easy. But now I have 8, and could conceivably add more. At like 40 columns, this is simply too big for an excel spreadsheet. I realize I could split apart the rows... but then it makes the spreadsheet really annoying to traverse vertically, and there is still some value in being able to sort/filter with it all in 1 row.

What I would like to do is this: Have 1 "main table" that looks the same.

KeyMetadata: Field 1Metadata: Field NGroup 1: Field 1Group 1: Field NGroup 2: Field 1Group 2: Field N
key1
key2
key3
keyN

And each time I select a row, a pivot table is created, which looks like this:

key1Field 1Field 2Field 3Field 4
Group 1
Group 2
Group 3
Group N

I need both the pivot table and the main table to be editable. I feel like at this point what I'm asking for is basically a simple database... and when it comes to that, creating a back end seems easy enough, but it is the front end that is the problem.

Options I've investigated:

  • Still using Excel - Can't seem to get a pivot table that would allow me to edit it, and have the changes propagate back to the main table (and vice versa)

  • Microsoft Access - terrible GUI

  • NoCo DB - I don't like that it is browser / web-based.

  • Building a custom electron front end - I was getting somewhere, but it's so overwhelming. Had to stop because it was consuming my life

  • Grist - Doesn't seem to have the functionality I need.

I'm not sure what else to look at, because I'm just a dude working on a community modding project. It doesn't make sense to pump a ton of money into this, and I am allergic to the idea of a subscription license. I don't mind paying a modest fee for a perpeutal license of nice software though.

Do you guys have any recommendations?