-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hi @diraneyya. Linking these two tables is definitely possible in Mathesar! Let me show you a few ways. First, a point of clarification. To link two tables, the foreign key does not need to reference a primary key. As long as the Mathesar lets you create a relationship in two ways:
This second approach sounds like what you're looking for. It will turn the ![]() As you can see, after creating the new foreign key constraint the ip_address column in Mathesar will display as a link to the Geolocation table: ![]() P.S: You're correct that Mathesar currently only allows users to create integer and UUID primary keys from the UI. Our goal with Mathesar is to give users access to all of the power of SQL without creating new abstractions on top of SQL. We also try to expose good defaults in the UI. We'd eventually like to allow users to create all possible types of primary keys in Mathesar. Let me know if you have further questions! Thanks. Here's the SQL I used when producing those screenshots: CREATE TABLE public.geolocation (
id SERIAL PRIMARY KEY,
ip_address TEXT NOT NULL UNIQUE,
country_code TEXT,
isp TEXT
);
CREATE TABLE public.routing (
id SERIAL PRIMARY KEY,
fqdn TEXT,
ip_address TEXT,
hops INTEGER,
latency NUMERIC
); |
Beta Was this translation helpful? Give feedback.
Hi @diraneyya. Linking these two tables is definitely possible in Mathesar! Let me show you a few ways.
First, a point of clarification. To link two tables, the foreign key does not need to reference a primary key. As long as the
ip_address
column on the referenced table (Geolocation, in your example) is bothUNIQUE
andNOT NULL
, it can be used to define a foreign key relationship, even if it's aTEXT
column.Mathesar lets you create a relationship in two ways:
Tabl…