public function createNewRecords(int $pageId, array $tableRecordData): array
    {
        $dataMap = [];
        $newTableIds = [];
        $currentUid = null;
        $previousTableName = null;
        $previousUid = null;
        foreach ($tableRecordData as $tableName => $recordData) {
            $recordData = $this->resolvePreviousUid($recordData, $currentUid);
            if (!isset($recordData['pid'])) {
                $recordData['pid'] = $pageId;
            }
            $currentUid = StringUtility::getUniqueId('NEW');
            $newTableIds[$tableName][] = $currentUid;
            $dataMap[$tableName][$currentUid] = $recordData;
            if ($previousTableName !== null && $previousUid !== null) {
                $dataMap[$previousTableName][$previousUid] = $this->resolveNextUid(
                    $dataMap[$previousTableName][$previousUid],
                    $currentUid
                );
            }
            $previousTableName = $tableName;
            $previousUid = $currentUid;
        }
        $this->createDataHandler();
        $this->dataHandler->start($dataMap, []);
        $this->dataHandler->process_datamap();

        foreach ($newTableIds as $tableName => &$ids) {
            foreach ($ids as &$id) {
                if (!empty($this->dataHandler->substNEWwithIDs[$id])) {
                    $id = $this->dataHandler->substNEWwithIDs[$id];
                }
            }
        }

        return $newTableIds;
    }