Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for composite primary key #1450

Open
kanekoshoyu opened this issue Jan 17, 2024 · 0 comments
Open

Support for composite primary key #1450

kanekoshoyu opened this issue Jan 17, 2024 · 0 comments

Comments

@kanekoshoyu
Copy link

kanekoshoyu commented Jan 17, 2024

Hi, I was wondering if there is any plan for a composite primary key in GlueSQL (esp shared memory)

Currently below is valid

    let sql = "   CREATE TABLE market (
            symbol TEXT NOT NULL PRIMARY KEY,
            side UINT8 NOT NULL,
            level UINT8 NOT NULL,
            price DECIMAL NOT NULL,
            volume DECIMAL NOT NULL,
            exchange UINT8 NOT NULL,
        )"

when we insert another row with the same symbol, it will return error.

duplicate entry 'Str("ZEN")' for primary_key field

This is great, but I was wondering if there is any plan for support in things like below

    let sql = "   CREATE TABLE market (
            symbol TEXT NOT NULL,
            side UINT8 NOT NULL,
            level UINT8 NOT NULL,
            price DECIMAL NOT NULL,
            volume DECIMAL NOT NULL,
            exchange UINT8 NOT NULL,
            PRIMARY KEY (symbol, level, exchange)
        )"

where only the unique combination of (symbol, level, exchange) is allowed. I tried the above but it did not do anything, so I believe it is not implemented yet.
https://www.geeksforgeeks.org/composite-key-in-sql/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant