Question: I want to delete duplicate rows from a table based on a condition.

e.g.,
Table ABC: 

```
ID  Name    Pin Status
111 Pope    909 New
222 Jazz    909 New
333 Volk    767 Assigned
444 Audi    767 New
555 Pink    435 New

```

I want to remove duplicate records which has same 'Pin' based on below conditions:

1. If both same Pin records have a Status of New – Delete any one of them.
2. If one of the same Pin records have a Status of New and the other have a Status of Assigned - Delete the 'New' status record.

I wrote the below SQL but I want to know if there is a better way to handle this using PK.

For 1:

```
DELETE FROM ABC WHERE ID IN (
SELECT
  a.id
FROM ABC a
WHERE a.rowid <
  (SELECT max(rowid)
  FROM  ABC  b
  WHERE b.pin = a.pin
  AND a.status  = b.status
  AND b.status  in ('New')
  )
);

```

For 2:

```
DELETE FROM ABC WHERE ID IN (
SELECT
  a.id
FROM ABC a
WHERE a.rowid <
  (SELECT max(rowid)
  FROM  ABC  b
  WHERE b.pin = a.pin
  AND a.status  <> b.status
  AND a.status  in ('New')
  AND b.status  in ('Assigned')
  )
);

```

Answer: 
Unless you would like to limit the operations that can be preformed on that data member, I would recommend using the public member. If all you are doing is wrapping the methods with your own method names, it doesn't make sense to have them there.
* Generally, you should avoid public derivation if IS-A relationship is not respected as it cause an higher coupling that composition.
* You should also avoid public member as it can make the application harder to maintain in the future.
* If you could use `PointerSet` directly in your second sample, then in version 1, you could have derived directly from `PointerSet` too. Thus the comparison is unfair.

**In practice, acceptable compromises depend a lot on the actual purpose of each class.** Extra indirections are useless if they don't give any benefits (reduced compilation dependencies, access/visibility control, extra functionalities, code reuse opportunities...)