We want to set up the user’s details (i.e. Users, person, person_name, role) through SQL script.
Actually we are trying to insert records in person_name table for creating users through SQL script, Now we can insert multiple records with the same person_id in the person_name table.
I think it should not happen that insertion of multiple times with the same person_id in person_name table therefore can have a unique constraint on column “person_id” on the openmrs table “person_name”.
The support for multiple names per person is by design. There may be circumstances where we want to record multiple names for a person. As a trivial example, it is often useful to track names that a person has been previously known by (people do actually change their legal name from time to time) or it may be useful to record alternate spellings of names or other names in other alphabets. Also bear in mind that the same person_name is used not just for users, but also for patients. While in some circumstances, it may be useful to only support one name (or one preferred name) per person, this seems too draconian a rule to apply universally to all person objects.
To add to @ibacher, the ability to store multiple names for a person is also useful when matching and merging patients.
Thanks for your valuable inputs @ibacher and @mksd related to support for multiple names per person is by design and keep multiple names per person is needed for different scenarios.