private ORASSNode processNaryRel(String relName, ORASSNode parent, List<String> entityOrder) throws MainException{
		ORASSNode node1 = parent;
		for (int i = 0; i< entityOrder.size(); i++){
			String entityName = entityOrder.get(i);
			logger.info("process n-ary entity " + entityName);
			if (i==0 && entityName != parent.getName()){
				throw new MainException("The parent of N-ary relationship "+ relName+" is inconsistent with the order of the entities specified by the user");
			}
			
			Vector<ErdNode> links = erdnodes.get(entityName).getLinks();
			// process the links connected to this node other than the n-ary rel link
			for(int j=0; j < links.size(); j++){
				ErdNode relatedNode = links.get(j);
				if(!relatedNode.getTableName().equals(relName)){
						ErdNodeType nodeType = relatedNode.getErdNodeType();
						if(nodeType == ErdNodeType.ENTITY_TYPE || nodeType == ErdNodeType.WEAK_ENTITY_TYPE){
							if(!processedNodes.contains(relatedNode.getTableName())){
								ORASSNode child = processEntity(relatedNode);
								node1.addChildren(child);
								logger.info("add child " + child.getName() + " to " + entityName);
							}
						} else { // The related node is a parent of a weak entity
							processRelationship(relatedNode, node1);
						}
					
				}
			}
			// process the n-ary rel link
			if(i<entityOrder.size()-1){
				// If the node is not the last entity in the n-ary relationship
				String nextEntity = entityOrder.get(i+1);
				ErdNode erdNode2 = erdnodes.get(nextEntity);
				ORASSNode node2 = createORASSNode(nextEntity, erdNode2.getOriginalTableName());
				List<ColumnDetail> attrs = erdnodes.get(nextEntity).getAttributes();
				for(int j=0; j<attrs.size(); j++){
					node2.addAttribute(attrs.get(j));
					//logger.info("add attribute " + attrs.get(j).getName() + " to " + nextEntity);
				}
				processIsARel(erdNode2);
				node1.addChildren(node2);
				node1.addChildRelation(node2, rels.get(relName).getOriginalTableName());
				logger.info("add child " + node2.getName() + " to " + node1.getName());
				processedNodes.add(node2.getName());
				node1 = node2;
			} else{
				// Add the attributes of the N-ary relationship to the last entity in the entity list
				processRelAttributes(relName, node1);
			}
			processedNodes.add(entityName);
		}
		logger.info("processed n-ary relationship " +  relName);
		return parent;
	}