0

In an SQLite database, I have a table called people that has columns prefix, first_name, middle_name, last_name, and suffix. The full name is the concatenation of all of these columns, separated by spaces. Is there any way to create a constraint that forces the full name to be unique (i.e., no two rows can have the same five values for prefix, first_name, middle_name, last_name, and suffix)?

laptou
  • 6,389
  • 2
  • 28
  • 59

1 Answers1

2

Yes. Just put a unique constraint/index on all five columns:

create unique index unq_people_name on people(prefix, first_name, middle_name, last_name, suffix);

You do realize, of course, that some people do have identical names.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786