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

"Primary key" constraint still generates an id column #69

Closed
o1lo01ol1o opened this issue May 4, 2021 · 3 comments
Closed

"Primary key" constraint still generates an id column #69

o1lo01ol1o opened this issue May 4, 2021 · 3 comments

Comments

@o1lo01ol1o
Copy link

o1lo01ol1o commented May 4, 2021

Perhaps related to #68, adding a version of the following constraint from the examples to my schema still produces an id column with a primary key constraint when I export via JDBC. I would expect that the primary key should be set on the composite attribute and there would be no id column, but maybe this implementation is by design?

#####################################/
#primary key constraints

schema Sch = literal : Ty {
	entities
		E
	attributes
		att1 att2 att3 : E -> dom
}

#says (att1,att2) is a primary key
constraints PkForSch = literal : Sch {
	forall x y : E
	where x.att1 = y.att1  x.att2 = y.att3
	->
	where x.att3 = y.att3
}
instance I = chase PkForSch Sch

command go = export_jdbc_instance i  "jdbc:postgresql://localhost:5432/foo" "" 
@wisnesky
Copy link
Contributor

wisnesky commented May 4, 2021

JDBC export is definitely not smart enough to look inside PkForSch-- and for good reason; it's a tough theorem proving task to determine if for example an arbitrary constraint is equivalent to a PK. The JDBC export just exports into 'categorical normal form', where every exported row gets a new unique single column PK. to make matters worse because of SQL's nulls and 3 valued logic it's not necessarily even the case that CQL constraints that looks like PKs actually are

@o1lo01ol1o
Copy link
Author

gotcha, thanks!

@wisnesky
Copy link
Contributor

wisnesky commented May 4, 2021

btw, we have an alternate SQL import pathway now that goes through the system catalog / INFORMATION SCHEMA views. We should chat offline sometime if you're in an environment where the exact semantics of SQL really matters.

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

No branches or pull requests

2 participants