jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes SQL check constraint Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL check constraint" Watch "SQL check constraint" New topic
Author

SQL check constraint

Juhan Voolaid
Ranch Hand

Joined: Nov 18, 2003
Posts: 179
Hi

It is only about SQL (DDL) and to be more specific - about PostgreSQL.

I have to create a table coordinates with rows: x integer, y integer, id integer, data_set integer. And I allso must specify that in one data_set, there is no dublicated set of coordinates.

My first attempt was like that:

But this one fails, because it does not care about data_set_ID.

So if there is any SQL guru out there, help is very welcome. How would you complete this, or what would you add to the code above?


thanx
[ June 11, 2006: Message edited by: Juhan Voolaid ]
Juhan Voolaid
Ranch Hand

Joined: Nov 18, 2003
Posts: 179
Daaaahhhh ...

The solution is more simple than I could excpect in my wildest dreams:

UNIQUE (x, y, data_set_id)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

Juhan,
Thanks for posting the solution for others who see this thread in the future.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL check constraint
 
Similar Threads
Multiple columns having same foreign key
Displaying Dynamic Nested Menu in JSP
Hibernate mapping doubt
Hibernate: Found two representations of same collection
Syntax error for Access Database