In yugabyte, Can table1 have foreign key constraint with primary key of table 2?
Does yugabyte provide referential integrity constraint?
In yugabyte, Can table1 have foreign key constraint with primary key of table 2?
Does yugabyte provide referential integrity constraint?
Yes sure. In YSQL, with same same syntax as PostgreSQL:
@FranckPachot I don’t get this.
We are using the yugabyte database in production, but with client driver ycql(instead of ysql)
Coming from MySQL & MsSql backgorund, just wondering,
How does a change in client driver(YSQL instead of YCQL) change the behavior of database schema? that can ensure foreign key constraints, with same yugabyte DB, just by changing the client driver…
Can’t we introduce foreign key constraints using YCQL client driver?
Ok, so no you cannot use foreign keys on tables created with the YCQL API. But you can create tables with the YSQL API and then have foreign key. The two APIs share the same database, but isolated from eachother.
If you want to use relational tables, referential integrity, transactions… like in a SQL database then you should use the YSQL API. The YCQL API is for cassandra-like microservices.
Currently, you cannot read YCQL from YSQL so you need an external tool to transfer data from one to the other, for example. We will enable access through the Forign Data Wrapper in a future release: [YSQL] Access YCQL tables via the YSQL API · Issue #830 · yugabyte/yugabyte-db · GitHub
There’s is more info about the API isolation: FAQs about YugabyteDB API compatibility | YugabyteDB Docs
Clarification: YSQL and YCQL are much more than just APIs in a usual sense, they are entirely different query layers.
While they both are backed by the same low-level DocDB (responsible for storage, replication, etc.), syntax, functionality, behavior, performance would all differ drastically.
As such, there’s no interop possible between YSQL and YCQL.
So that means,
Using ysql, can we introduce database triggers and stored procedures, unlike ycql?
Using ycql, with begin transaction
and end transaction
, does yugabyte database ensure, write consistency, for the queries that modify more than one table ?
does multi sharding of a table happens using ycql? But not ysql…
Is partition key concept visible only through ycql but not ysql?