I am working on a geodatabase. In some of my features, I would like to add a field, in which I will type the values on my own. On this field no duplicates must be allowed. In other words I want it to be a unique value field. I know ObjectID exists to certain uniqueness of the object, but I am working on a relational db and I want this field to be used as primary key.
I have tried adding a field and through access editing it as a "no duplicates allowed" field, but after that, I cannot edit in arcmap and the message "Warning: Unique index on non-OID field" appears.
Answer
You are not supposed to edit your personal geodatabase from MS Access since this may corrupt your geodatabase and introduce unexpected behaviour. In file and personal geodatabase, you are working with feature classes and tables each of which already has an unique ID field, i.e., ObjectID.
ObjectID, however, can be easily changed when a feature is updated or modified, so you should not depend on the ObjectID field in your database design. This field is used internally within the ArcGIS. Your option is to create a new field which you will take care yourself and make it a "key" field, however as you probably know each table can only have one unique index and it is already taken for the ObjectID field, that is why you are getting this kind of message. You will need to make sure that the field you will create yourself is unique through custom approach, such as setting up a geodatabase domain with pre-defined values, which user will be able to choose from. You could also use triggers to make sure that the values you enter into the field are unique.
If you need more advanced relational database design, you will need to move to an enterprise geodatabase, because the DBMS provides better support for this kind of operations. I have multiple feature classes with in SQL Server database that have unique constraints.
It is worth noting that, in ArcMap, when you edit attribute fields of an SDE feature class for which you have set the unique constraint in SQL Server, and try to enter an existing value in a field with defined unique constraint, you will get an error message and the value will not be entered.
Then you could use the Attribute Inspector (available from the Editing toolbar > Editor > Editing Options > Attributes tab). Check the Display the attributes dialog before storing new features option. This will allow you to enter attributes prior to writing rows to your database at the DBMS level.
No comments:
Post a Comment