private void verifyPrimaryKeyUniqueness(Tuple newTuple, List<Tuple> existingTuples)
			throws DatabaseException {
		
		// get types and primary key attributes of this tuple
		int[] primaryKeyPositions = schema.getPrimaryKeyPositions();
		Object[] newTupleKeyValues = new Object[primaryKeyPositions.length];
		Attribute.Type[] newTupleKeyTypes = new Attribute.Type[primaryKeyPositions.length];
		for (int i=0; i<primaryKeyPositions.length; ++i){
			newTupleKeyValues[i] = newTuple.getValueAt(primaryKeyPositions[i]);
			newTupleKeyTypes[i] = schema.getAttributes()[primaryKeyPositions[i]].getType();
		}
		
		// go through all existingTuples and compare key attribute values
		for (Tuple existingTuple : existingTuples) {
			boolean keyIsDifferent = false;
			for (int i=0; i<primaryKeyPositions.length; ++i) {
				Object tKeyValue = existingTuple.getValueAt(primaryKeyPositions[i]);
				if (!Tuple.valuesEqual(newTupleKeyTypes[i], newTupleKeyValues[i], tKeyValue)) {
					keyIsDifferent = true;
					break;
				}
			}
			if (!keyIsDifferent) {
				throw new DatabaseException("Primary key uniqueness constraint not met.");
			}
		}
	}