public  void generateDatabase(int transactionCount, int maxDistinctItems, int maxItemCountPerTransaction,
			String output) throws IOException {
		
		// We create a BufferedWriter to write the database to disk
		BufferedWriter writer = new BufferedWriter(new FileWriter(output)); 
		// For the number of transactions to be generated
		for (int i = 0; i < transactionCount; i++) {
			// if it is not the first one, we write on a new line
			if(i != 0){
				writer.newLine();
			}
			// We randomly decide how many items will appear in this transaction
			int itemCount = random.nextInt(maxItemCountPerTransaction) + 1;
			
			// This hashset will be used to remember which items have
			// already been added to this itemset.
			HashSet<Integer> alreadyAdded = new HashSet<Integer>();
			
			// create an arraylist to store items from the itemset that will be generated
			List<Integer> itemset = new ArrayList<Integer>();
			// for the number of items that was decided above
			for (int j = 0; j < itemCount; j++) {
				// we generate the item randomly and write it to disk
				int item = random.nextInt(maxDistinctItems) + 1;
				// if we already added this item to this itemset
				// we choose another one
				while(alreadyAdded.contains(item)){
					item = random.nextInt(maxDistinctItems) + 1;
				}
				alreadyAdded.add(item);
				itemset.add(item);
			}
			// sort the itemset
			Collections.sort(itemset);
			// write the itemset
			for(int j=0; j< itemset.size(); j++){
				if(j != 0){
					writer.write(" ");
				}
				writer.write(""+itemset.get(j));
			}
			
		}
		writer.close(); // close the file.
	}