code: public void addRelationToResource(
          CmsDbContext dbc,
          CmsResource resource,
          CmsResource target,
          CmsRelationType type,
          boolean importCase)
      throws CmsException {
  
          if (type.isDefinedInContent()) {
              throw new CmsIllegalArgumentException(
                  Messages.get().container(
                      Messages.ERR_ADD_RELATION_IN_CONTENT_3,
                      dbc.removeSiteRoot(resource.getRootPath()),
                      dbc.removeSiteRoot(target.getRootPath()),
                      type.getLocalizedName(dbc.getRequestContext().getLocale())));
          }
          CmsRelation relation = new CmsRelation(resource, target, type);
          getVfsDriver(dbc).createRelation(dbc, dbc.currentProject().getUuid(), relation);
          if (!importCase) {
              // log it
              log(
                  dbc,
                  new CmsLogEntry(
                      dbc,
                      resource.getStructureId(),
                      CmsLogEntryType.RESOURCE_ADD_RELATION,
                      new String[] {relation.getSourcePath(), relation.getTargetPath()}),
                  false);
              // touch the resource
              setDateLastModified(dbc, resource, System.currentTimeMillis());
          }
      }
docs: Adds a new relation to the given resource.<p>
  
  @param dbc the database context
  @param resource the resource to add the relation to
  @param target the target of the relation
  @param type the type of the relation
  @param importCase if importing relations
  
  @throws CmsException if something goes wrong