[FEATURE] Relationship between tables with composite keys
- Dominant language
- JavaScript
- Stars
- 39.5k
- Forks
- 3.2k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 16
Description
**Is your feature request related to a problem? Please describe.**
My table have a composite key. I cannot connect my composite key to another table.
**Describe the solution you'd like**
Possibility to select multiple fields to compose the relationship.
**Additional context**
I'll try to explain with an example of my expected result:
```
CREATE TABLE [product] (
[company] INTEGER NOT NULL,
[code] VARCHAR(25) NOT NULL,
[name] VARCHAR(255),
PRIMARY KEY([company], [code])
);
GO
CREATE TABLE [product_variant] (
[company] INTEGER NOT NULL,
[product] VARCHAR(25) NOT NULL,
[variant] CHAR(25) NOT NULL,
[name] VARCHAR(255),
PRIMARY KEY([company], [product], [variant])
);
GO
CREATE TABLE [product_barcode] (
[company] INTEGER NOT NULL,
[barcode] VARCHAR(64) NOT NULL,
[product] VARCHAR(25) NOT NULL,
[variant] CHAR(25) NOT NULL,
PRIMARY KEY([company], [barcode])
);
GO
ALTER TABLE product_variant
ADD CONSTRAINT FK_product_variant_product
FOREIGN KEY (company, product)
REFERENCES product(company, code);
GO
ALTER TABLE product_barcode
ADD CONSTRAINT FK_product_barcode_variant
FOREIGN KEY (company, product, variant)
REFERENCES product_variant(company, product, variant);
```
Contributor guide
Research direction
No files, tests, or entry points are named in the issue. Start by locating how relationships are modeled and exported to SQL, then determine how multiple field pairs could be represented and edited. Done means the examples' composite foreign keys can be created and the corresponding SQL is generated correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100