Depends on the DBMS I suppose.  
But I believe that constraints are in the same namespace as the 
tables in most (if not all) DMBSs so your example should work fine.

(Of course assuming the DBA didn't happen to create a PKPRODUCT table
somewhere)

As for if they need to be universally unique, that's really a DMBS
issue.

Example:
PGSQL has one namespace for the database instance.  So there can only be
one table/constraint/object with a specific name.  Users "tom" and "bob"
share the single namespace.

ORACLE on the other hand, has a seperate namespace for each user.  
So, if you logged in as "tom", and created Product/pkProduct
What actually gets created is "tom.Product" and "tom.pkProduct"

But if "bob" logs in, it's "bob.Product" and "bob.pkProduct"

So, I guess i'd say that you only need to be unique in a single DB pool (assuming
there aren't 2 pools with the same credentials/connection props)

I'm not sure with other DBMSs, but with oracle, you can leave out the
constraint name, and it will generate it for you.  So you don't have
to worry about uniqueness.  But I'm not sure that's universal to all
DBMSs.

-David



On Thu, 29 Nov 2001, Dain Sundstrom wrote:

> Does a table constraint name need to be universally unique, unique within
> the table, or not unique at all?
> 
> By constraint name, I mean pkProduct and fkCategory in the SQL that follow:
> 
> CREATE TABLE product
> (id  VARCHAR(40),
> name VARCHAR(100),
> category VARCHAR(40),
> ...
> CONSTRAINT pkProduct PRIMARY KEY (id),
> CONSTRAINT fkCategory FOREIGN KEY (category) 
>       REFERENCES categroy(id))
> 
> -dain
> 
> 
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to