There is a kinda ETL task of importing data from csv to the database in project with legacy codebase with legacy database. The data should be validated before persisting to database.
Validation includes validation per row, such as data format checking, mandatory field checking etc., and global uniqueness validation.
The current database table, where data to be imported to, is in the following state:
- There is no unique constraint with composite key
- The table is already way big
- Query is way more than update onto the database
Question is about the design of global uniqueness validation : Should global validation be done in the backend codebase or mainly by adding unique constraint to the database?