how to ensure only one record exist with the same name.
hi,
Could some one tell me how to ensure that only one record with the same name exits. i have a table called imageinfo, with 4 columns, image_id, image_name, image_size and image_date. I would like to ensure that only one record exist with the same name. thanks, Mel |
Not sure what you mean. Does this help?
Code:
struct table_t { |
I think he was talking SQL .....
|
I've never used SQL before, but I did play with Borland's Database Engine in Delphi a little.
So, aside from the brute force approach: 1) Read first record's filename 2) Look for a match in the rest of the database 3) Read second record's filename 4) Look for a match in the rest of the database 5) ... There was an easier method in Borland: 1) Create a secondary index in the table based on the filename field (secondary indices do not need to contain only unique elements) 2) Sort the table based on this secondary index 3) Any duplicate filenames ought to be found consecutively when you walk through each record in the table That assumes the filenames are case-sensitive (i.e. File1.img != file1.img). |
1. SQL: u may make the column in the db "unique"
so the db will not allow a 2nd entry with the same value 2. if u manipulate data in a table using a programming language it would be useful to tell as which language u use, right? i. e. there are different functions to retrieve the number of rows returned by a sql query cheers, jens |
There's that marvelous thing in SQL called
an index, and one variant thereof supports the feature unique ;) Cheers, Tink P.S.: Once your database grows you'll find that indexing also makes read access much faster ;) |
All times are GMT -5. The time now is 11:50 PM. |