diff --git a/libraries/classes/Normalization.php b/libraries/classes/Normalization.php
new file mode 100644
index 0000000000..ee4131af18
--- /dev/null
+++ b/libraries/classes/Normalization.php
@@ -0,0 +1,997 @@
+getColumns();
+ $columnTypeList = $types[$colTypeCategory];
+ }
+ $GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
+ $columns = $GLOBALS['dbi']->getColumns(
+ $db, $table, null,
+ true, $GLOBALS['userlink']
+ );
+ $type = "";
+ $selectColHtml = "";
+ foreach ($columns as $column => $def) {
+ if (isset($def['Type'])) {
+ $extracted_columnspec = Util::extractColumnSpec($def['Type']);
+ $type = $extracted_columnspec['type'];
+ }
+ if (empty($columnTypeList)
+ || in_array(mb_strtoupper($type), $columnTypeList)
+ ) {
+ if ($listType == 'checkbox') {
+ $selectColHtml .= ''
+ . htmlspecialchars($column) . ' [ '
+ . htmlspecialchars($def['Type']) . ' ]';
+ } else {
+ $selectColHtml .= '';
+ }
+ }
+ }
+ return $selectColHtml;
+ }
+
+ /**
+ * get the html of the form to add the new column to given table
+ *
+ * @param integer $num_fields number of columns to add
+ * @param string $db current database
+ * @param string $table current table
+ * @param array $columnMeta array containing default values for the fields
+ *
+ * @return string HTML
+ */
+ public static function getHtmlForCreateNewColumn(
+ $num_fields, $db, $table, $columnMeta=array()
+ ) {
+ $cfgRelation = Relation::getRelationsParam();
+ $content_cells = array();
+ $available_mime = array();
+ $mime_map = array();
+ if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
+ $mime_map = Transformations::getMIME($db, $table);
+ $available_mime = Transformations::getAvailableMIMEtypes();
+ }
+ $comments_map = Relation::getComments($db, $table);
+ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
+ $content_cells[$columnNumber] = array(
+ 'columnNumber' => $columnNumber,
+ 'columnMeta' => $columnMeta,
+ 'type_upper' => '',
+ 'length_values_input_size' => 8,
+ 'length' => '',
+ 'extracted_columnspec' => array(),
+ 'submit_attribute' => null,
+ 'comments_map' => $comments_map,
+ 'fields_meta' => null,
+ 'is_backup' => true,
+ 'move_columns' => array(),
+ 'cfgRelation' => $cfgRelation,
+ 'available_mime' => isset($available_mime)?$available_mime:array(),
+ 'mime_map' => $mime_map
+ );
+ }
+
+ return Template::get(
+ 'columns_definitions/table_fields_definitions'
+ )
+ ->render(
+ array(
+ 'is_backup' => true,
+ 'fields_meta' => null,
+ 'mimework' => $cfgRelation['mimework'],
+ 'content_cells' => $content_cells
+ )
+ );
+ }
+ /**
+ * build the html for step 1.1 of normalization
+ *
+ * @param string $db current database
+ * @param string $table current table
+ * @param string $normalizedTo up to which step normalization will go,
+ * possible values 1nf|2nf|3nf
+ *
+ * @return string HTML for step 1.1
+ */
+ public static function getHtmlFor1NFStep1($db, $table, $normalizedTo)
+ {
+ $step = 1;
+ $stepTxt = __('Make all columns atomic');
+ $html = "
"
+ . __('First step of normalization (1NF)') . "
";
+ $html .= "
" .
+ ""
+ . "
";
+ return $html;
+ }
+
+ /**
+ * build the html contents of various html elements in step 1.2
+ *
+ * @param string $db current database
+ * @param string $table current table
+ *
+ * @return string HTML contents for step 1.2
+ */
+ public static function getHtmlContentsFor1NFStep2($db, $table)
+ {
+ $step = 2;
+ $stepTxt = __('Have a primary key');
+ $primary = Index::getPrimary($table, $db);
+ $hasPrimaryKey = "0";
+ $legendText = __('Step 1.') . $step . " " . $stepTxt;
+ $extra = '';
+ if ($primary) {
+ $headText = __("Primary key already exists.");
+ $subText = __("Taking you to next step…");
+ $hasPrimaryKey = "1";
+ } else {
+ $headText = __(
+ "There is no primary key; please add one. "
+ . "Hint: A primary key is a column "
+ . "(or combination of columns) that uniquely identify all rows."
+ );
+ $subText = ''
+ . Util::getIcon(
+ 'b_index_add.png', __(
+ 'Add a primary key on existing column(s)'
+ )
+ )
+ . '';
+ $extra = __(
+ "If it's not possible to make existing "
+ . "column combinations as primary key"
+ ) . " "
+ . ''
+ . __('+ Add a new primary key column') . '';
+ }
+ $res = array(
+ 'legendText' => $legendText,
+ 'headText' => $headText,
+ 'subText' => $subText,
+ 'hasPrimaryKey' => $hasPrimaryKey,
+ 'extra' => $extra
+ );
+ return $res;
+ }
+
+ /**
+ * build the html contents of various html elements in step 1.4
+ *
+ * @param string $db current database
+ * @param string $table current table
+ *
+ * @return string HTML contents for step 1.4
+ */
+ public static function getHtmlContentsFor1NFStep4($db, $table)
+ {
+ $step = 4;
+ $stepTxt = __('Remove redundant columns');
+ $legendText = __('Step 1.') . $step . " " . $stepTxt;
+ $headText = __(
+ "Do you have a group of columns which on combining gives an existing"
+ . " column? For example, if you have first_name, last_name and"
+ . " full_name then combining first_name and last_name gives full_name"
+ . " which is redundant."
+ );
+ $subText = __(
+ "Check the columns which are redundant and click on remove. "
+ . "If no redundant column, click on 'No redundant column'"
+ );
+ $extra = self::getHtmlForColumnsList($db, $table, 'all', "checkbox") . ""
+ . ''
+ . '';
+ $res = array(
+ 'legendText' => $legendText,
+ 'headText' => $headText,
+ 'subText' => $subText,
+ 'extra' => $extra
+ );
+ return $res;
+ }
+
+ /**
+ * build the html contents of various html elements in step 1.3
+ *
+ * @param string $db current database
+ * @param string $table current table
+ *
+ * @return string HTML contents for step 1.3
+ */
+ public static function getHtmlContentsFor1NFStep3($db, $table)
+ {
+ $step = 3;
+ $stepTxt = __('Move repeating groups');
+ $legendText = __('Step 1.') . $step . " " . $stepTxt;
+ $headText = __(
+ "Do you have a group of two or more columns that are closely "
+ . "related and are all repeating the same attribute? For example, "
+ . "a table that holds data on books might have columns such as book_id, "
+ . "author1, author2, author3 and so on which form a "
+ . "repeating group. In this case a new table (book_id, author) should "
+ . "be created."
+ );
+ $subText = __(
+ "Check the columns which form a repeating group. "
+ . "If no such group, click on 'No repeating group'"
+ );
+ $extra = self::getHtmlForColumnsList($db, $table, 'all', "checkbox") . ""
+ . ''
+ . '';
+ $primary = Index::getPrimary($table, $db);
+ $primarycols = $primary->getColumns();
+ $pk = array();
+ foreach ($primarycols as $col) {
+ $pk[] = $col->getName();
+ }
+ $res = array(
+ 'legendText' => $legendText,
+ 'headText' => $headText,
+ 'subText' => $subText,
+ 'extra' => $extra,
+ 'primary_key' => json_encode($pk)
+ );
+ return $res;
+ }
+
+ /**
+ * build html contents for 2NF step 2.1
+ *
+ * @param string $db current database
+ * @param string $table current table
+ *
+ * @return string HTML contents for 2NF step 2.1
+ */
+ public static function getHtmlFor2NFstep1($db, $table)
+ {
+ $legendText = __('Step 2.') . "1 " . __('Find partial dependencies');
+ $primary = Index::getPrimary($table, $db);
+ $primarycols = $primary->getColumns();
+ $pk = array();
+ $subText = '';
+ $selectPkForm = "";
+ $extra = "";
+ foreach ($primarycols as $col) {
+ $pk[] = $col->getName();
+ $selectPkForm .= ''
+ . htmlspecialchars($col->getName());
+ }
+ $key = implode(', ', $pk);
+ if (count($primarycols) > 1) {
+ $GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
+ $columns = (array) $GLOBALS['dbi']->getColumnNames(
+ $db, $table, $GLOBALS['userlink']
+ );
+ if (count($pk) == count($columns)) {
+ $headText = sprintf(
+ __(
+ 'No partial dependencies possible as '
+ . 'no non-primary column exists since primary key ( %1$s ) '
+ . 'is composed of all the columns in the table.'
+ ), htmlspecialchars($key)
+ ) . ' ';
+ $extra = '
' . __('Table is already in second normal form.')
+ . '
';
+ } else {
+ $headText = sprintf(
+ __(
+ 'The primary key ( %1$s ) consists of more than one column '
+ . 'so we need to find the partial dependencies.'
+ ), htmlspecialchars($key)
+ ) . ' ' . __(
+ 'Please answer the following question(s) '
+ . 'carefully to obtain a correct normalization.'
+ )
+ . ' ' . __(
+ '+ Show me the possible partial dependencies '
+ . 'based on data in the table'
+ ) . '';
+ $subText = __(
+ 'For each column below, '
+ . 'please select the minimal set of columns among given set '
+ . 'whose values combined together are sufficient'
+ . ' to determine the value of the column.'
+ );
+ $cnt = 0;
+ foreach ($columns as $column) {
+ if (!in_array($column, $pk)) {
+ $cnt++;
+ $extra .= "" . sprintf(
+ __('\'%1$s\' depends on:'), htmlspecialchars($column)
+ ) . " ";
+ $extra .= '
';
+ }
+ }
+ }
+ } else {
+ $headText = sprintf(
+ __(
+ 'No partial dependencies possible as the primary key'
+ . ' ( %1$s ) has just one column.'
+ ), htmlspecialchars($key)
+ ) . ' ';
+ $extra = '
' . __('Table is already in second normal form.') . '
';
+ }
+ $res = array(
+ 'legendText' => $legendText,
+ 'headText' => $headText,
+ 'subText' => $subText,
+ 'extra' => $extra,
+ 'primary_key' => $key
+ );
+ return $res;
+ }
+
+ /**
+ * build the html for showing the tables to have in order to put current table in 2NF
+ *
+ * @param array $partialDependencies array containing all the dependencies
+ * @param string $table current table
+ *
+ * @return string HTML
+ */
+ public static function getHtmlForNewTables2NF($partialDependencies,$table)
+ {
+ $html = '
' . sprintf(
+ __(
+ 'In order to put the '
+ . 'original table \'%1$s\' into Second normal form we need '
+ . 'to create the following tables:'
+ ), htmlspecialchars($table)
+ ) . '
'
+ );
+ $error = true;
+ break;
+ }
+ }
+ return array(
+ 'legendText' => __('End of step'),
+ 'headText' => $headText,
+ 'queryError' => $error,
+ 'extra' => $message
+ );
+ }
+
+ /**
+ * build the html for showing the new tables to have in order
+ * to put given tables in 3NF
+ *
+ * @param object $dependencies containing all the dependencies
+ * @param array $tables tables formed after 2NF and need to convert to 3NF
+ * @param string $db current database
+ *
+ * @return array containing html and the list of new tables
+ */
+ public static function getHtmlForNewTables3NF($dependencies, $tables, $db)
+ {
+ $html = "";
+ $i = 1;
+ $newTables = array();
+ foreach ($tables as $table=>$arrDependson) {
+ if (count(array_unique($arrDependson)) == 1) {
+ continue;
+ }
+ $primary = Index::getPrimary($table, $db);
+ $primarycols = $primary->getColumns();
+ $pk = array();
+ foreach ($primarycols as $col) {
+ $pk[] = $col->getName();
+ }
+ $html .= '
' . sprintf(
+ __(
+ 'In order to put the '
+ . 'original table \'%1$s\' into Third normal form we need '
+ . 'to create the following tables:'
+ ), htmlspecialchars($table)
+ ) . '
';
+ return $html;
+ }
+
+ /**
+ * check whether a particular column is dependent on given subset of primary key
+ *
+ * @param string $partialKey the partial key, subset of primary key,
+ * each column in key supposed to be backquoted
+ * @param string $column backquoted column on whose dependency being checked
+ * @param string $table current table
+ * @param integer $pkCnt distinct value count for given partial key
+ * @param integer $colCnt distinct value count for given column
+ * @param integer $totalRows total distinct rows count of the table
+ *
+ * @return boolean TRUE if $column is dependent on $partialKey, False otherwise
+ */
+ public static function checkPartialDependency(
+ $partialKey, $column, $table, $pkCnt, $colCnt, $totalRows
+ ) {
+ $query = 'SELECT '
+ . 'COUNT(DISTINCT ' . $partialKey . ',' . $column . ') as pkColCnt '
+ . 'FROM (SELECT * FROM ' . Util::backquote($table)
+ . ' LIMIT 500) as dt' . ';';
+ $res = $GLOBALS['dbi']->fetchResult($query, null, null, $GLOBALS['userlink']);
+ $pkColCnt = $res[0];
+ if ($pkCnt && $pkCnt == $colCnt && $colCnt == $pkColCnt) {
+ return true;
+ }
+ if ($totalRows && $totalRows == $pkCnt) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * function to get distinct values count of all the column in the array $columns
+ *
+ * @param array $columns array of backquoted columns whose distinct values
+ * need to be counted.
+ * @param string $table table to which these columns belong
+ *
+ * @return array associative array containing the count
+ */
+ public static function findDistinctValuesCount($columns, $table)
+ {
+ $result = array();
+ $query = 'SELECT ';
+ foreach ($columns as $column) {
+ if ($column) { //each column is already backquoted
+ $query .= 'COUNT(DISTINCT ' . $column . ') as \''
+ . $column . '_cnt\', ';
+ }
+ }
+ $query = trim($query, ', ');
+ $query .= ' FROM (SELECT * FROM ' . Util::backquote($table)
+ . ' LIMIT 500) as dt' . ';';
+ $res = $GLOBALS['dbi']->fetchResult($query, null, null, $GLOBALS['userlink']);
+ foreach ($columns as $column) {
+ if ($column) {
+ $result[$column] = $res[0][$column . '_cnt'];
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * find all the possible partial keys
+ *
+ * @param array $primaryKey array containing all the column present in primary key
+ *
+ * @return array containing all the possible partial keys(subset of primary key)
+ */
+ public static function getAllCombinationPartialKeys($primaryKey)
+ {
+ $results = array('');
+ foreach ($primaryKey as $element) {
+ foreach ($results as $combination) {
+ array_push(
+ $results, trim($element . ',' . $combination, ',')
+ );
+ }
+ }
+ array_pop($results); //remove key which consist of all primary key columns
+ return $results;
+ }
+}
diff --git a/libraries/normalization.lib.php b/libraries/normalization.lib.php
deleted file mode 100644
index ece61d7364..0000000000
--- a/libraries/normalization.lib.php
+++ /dev/null
@@ -1,982 +0,0 @@
-getColumns();
- $columnTypeList = $types[$colTypeCategory];
- }
- $GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
- $columns = $GLOBALS['dbi']->getColumns(
- $db, $table, null,
- true, $GLOBALS['userlink']
- );
- $type = "";
- $selectColHtml = "";
- foreach ($columns as $column => $def) {
- if (isset($def['Type'])) {
- $extracted_columnspec = Util::extractColumnSpec($def['Type']);
- $type = $extracted_columnspec['type'];
- }
- if (empty($columnTypeList)
- || in_array(mb_strtoupper($type), $columnTypeList)
- ) {
- if ($listType == 'checkbox') {
- $selectColHtml .= ''
- . htmlspecialchars($column) . ' [ '
- . htmlspecialchars($def['Type']) . ' ]';
- } else {
- $selectColHtml .= '';
- }
- }
- }
- return $selectColHtml;
-}
-
-/**
- * get the html of the form to add the new column to given table
- *
- * @param integer $num_fields number of columns to add
- * @param string $db current database
- * @param string $table current table
- * @param array $columnMeta array containing default values for the fields
- *
- * @return string HTML
- */
-function PMA_getHtmlForCreateNewColumn(
- $num_fields, $db, $table, $columnMeta=array()
-) {
- $cfgRelation = Relation::getRelationsParam();
- $content_cells = array();
- $available_mime = array();
- $mime_map = array();
- if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
- $mime_map = Transformations::getMIME($db, $table);
- $available_mime = Transformations::getAvailableMIMEtypes();
- }
- $comments_map = Relation::getComments($db, $table);
- for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
- $content_cells[$columnNumber] = array(
- 'columnNumber' => $columnNumber,
- 'columnMeta' => $columnMeta,
- 'type_upper' => '',
- 'length_values_input_size' => 8,
- 'length' => '',
- 'extracted_columnspec' => array(),
- 'submit_attribute' => null,
- 'comments_map' => $comments_map,
- 'fields_meta' => null,
- 'is_backup' => true,
- 'move_columns' => array(),
- 'cfgRelation' => $cfgRelation,
- 'available_mime' => isset($available_mime)?$available_mime:array(),
- 'mime_map' => $mime_map
- );
- }
-
- return PhpMyAdmin\Template::get(
- 'columns_definitions/table_fields_definitions'
- )
- ->render(
- array(
- 'is_backup' => true,
- 'fields_meta' => null,
- 'mimework' => $cfgRelation['mimework'],
- 'content_cells' => $content_cells
- )
- );
-}
-/**
- * build the html for step 1.1 of normalization
- *
- * @param string $db current database
- * @param string $table current table
- * @param string $normalizedTo up to which step normalization will go,
- * possible values 1nf|2nf|3nf
- *
- * @return string HTML for step 1.1
- */
-function PMA_getHtmlFor1NFStep1($db, $table, $normalizedTo)
-{
- $step = 1;
- $stepTxt = __('Make all columns atomic');
- $html = "
"
- . __('First step of normalization (1NF)') . "
";
- $html .= "
" .
- ""
- . "
";
- return $html;
-}
-
-/**
- * build the html contents of various html elements in step 1.2
- *
- * @param string $db current database
- * @param string $table current table
- *
- * @return string HTML contents for step 1.2
- */
-function PMA_getHtmlContentsFor1NFStep2($db, $table)
-{
- $step = 2;
- $stepTxt = __('Have a primary key');
- $primary = PhpMyAdmin\Index::getPrimary($table, $db);
- $hasPrimaryKey = "0";
- $legendText = __('Step 1.') . $step . " " . $stepTxt;
- $extra = '';
- if ($primary) {
- $headText = __("Primary key already exists.");
- $subText = __("Taking you to next step…");
- $hasPrimaryKey = "1";
- } else {
- $headText = __(
- "There is no primary key; please add one. "
- . "Hint: A primary key is a column "
- . "(or combination of columns) that uniquely identify all rows."
- );
- $subText = ''
- . Util::getIcon(
- 'b_index_add.png', __(
- 'Add a primary key on existing column(s)'
- )
- )
- . '';
- $extra = __(
- "If it's not possible to make existing "
- . "column combinations as primary key"
- ) . " "
- . ''
- . __('+ Add a new primary key column') . '';
- }
- $res = array(
- 'legendText' => $legendText,
- 'headText' => $headText,
- 'subText' => $subText,
- 'hasPrimaryKey' => $hasPrimaryKey,
- 'extra' => $extra
- );
- return $res;
-}
-
-/**
- * build the html contents of various html elements in step 1.4
- *
- * @param string $db current database
- * @param string $table current table
- *
- * @return string HTML contents for step 1.4
- */
-function PMA_getHtmlContentsFor1NFStep4($db, $table)
-{
- $step = 4;
- $stepTxt = __('Remove redundant columns');
- $legendText = __('Step 1.') . $step . " " . $stepTxt;
- $headText = __(
- "Do you have a group of columns which on combining gives an existing"
- . " column? For example, if you have first_name, last_name and"
- . " full_name then combining first_name and last_name gives full_name"
- . " which is redundant."
- );
- $subText = __(
- "Check the columns which are redundant and click on remove. "
- . "If no redundant column, click on 'No redundant column'"
- );
- $extra = PMA_getHtmlForColumnsList($db, $table, 'all', "checkbox") . ""
- . ''
- . '';
- $res = array(
- 'legendText' => $legendText,
- 'headText' => $headText,
- 'subText' => $subText,
- 'extra' => $extra
- );
- return $res;
-}
-
-/**
- * build the html contents of various html elements in step 1.3
- *
- * @param string $db current database
- * @param string $table current table
- *
- * @return string HTML contents for step 1.3
- */
-function PMA_getHtmlContentsFor1NFStep3($db, $table)
-{
- $step = 3;
- $stepTxt = __('Move repeating groups');
- $legendText = __('Step 1.') . $step . " " . $stepTxt;
- $headText = __(
- "Do you have a group of two or more columns that are closely "
- . "related and are all repeating the same attribute? For example, "
- . "a table that holds data on books might have columns such as book_id, "
- . "author1, author2, author3 and so on which form a "
- . "repeating group. In this case a new table (book_id, author) should "
- . "be created."
- );
- $subText = __(
- "Check the columns which form a repeating group. "
- . "If no such group, click on 'No repeating group'"
- );
- $extra = PMA_getHtmlForColumnsList($db, $table, 'all', "checkbox") . ""
- . ''
- . '';
- $primary = PhpMyAdmin\Index::getPrimary($table, $db);
- $primarycols = $primary->getColumns();
- $pk = array();
- foreach ($primarycols as $col) {
- $pk[] = $col->getName();
- }
- $res = array(
- 'legendText' => $legendText,
- 'headText' => $headText,
- 'subText' => $subText,
- 'extra' => $extra,
- 'primary_key' => json_encode($pk)
- );
- return $res;
-}
-
-/**
- * build html contents for 2NF step 2.1
- *
- * @param string $db current database
- * @param string $table current table
- *
- * @return string HTML contents for 2NF step 2.1
- */
-function PMA_getHtmlFor2NFstep1($db, $table)
-{
- $legendText = __('Step 2.') . "1 " . __('Find partial dependencies');
- $primary = PhpMyAdmin\Index::getPrimary($table, $db);
- $primarycols = $primary->getColumns();
- $pk = array();
- $subText = '';
- $selectPkForm = "";
- $extra = "";
- foreach ($primarycols as $col) {
- $pk[] = $col->getName();
- $selectPkForm .= ''
- . htmlspecialchars($col->getName());
- }
- $key = implode(', ', $pk);
- if (count($primarycols) > 1) {
- $GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
- $columns = (array) $GLOBALS['dbi']->getColumnNames(
- $db, $table, $GLOBALS['userlink']
- );
- if (count($pk) == count($columns)) {
- $headText = sprintf(
- __(
- 'No partial dependencies possible as '
- . 'no non-primary column exists since primary key ( %1$s ) '
- . 'is composed of all the columns in the table.'
- ), htmlspecialchars($key)
- ) . ' ';
- $extra = '
' . __('Table is already in second normal form.')
- . '
';
- } else {
- $headText = sprintf(
- __(
- 'The primary key ( %1$s ) consists of more than one column '
- . 'so we need to find the partial dependencies.'
- ), htmlspecialchars($key)
- ) . ' ' . __(
- 'Please answer the following question(s) '
- . 'carefully to obtain a correct normalization.'
- )
- . ' ' . __(
- '+ Show me the possible partial dependencies '
- . 'based on data in the table'
- ) . '';
- $subText = __(
- 'For each column below, '
- . 'please select the minimal set of columns among given set '
- . 'whose values combined together are sufficient'
- . ' to determine the value of the column.'
- );
- $cnt = 0;
- foreach ($columns as $column) {
- if (!in_array($column, $pk)) {
- $cnt++;
- $extra .= "" . sprintf(
- __('\'%1$s\' depends on:'), htmlspecialchars($column)
- ) . " ";
- $extra .= '
';
- }
- }
- }
- } else {
- $headText = sprintf(
- __(
- 'No partial dependencies possible as the primary key'
- . ' ( %1$s ) has just one column.'
- ), htmlspecialchars($key)
- ) . ' ';
- $extra = '
' . __('Table is already in second normal form.') . '
';
- }
- $res = array(
- 'legendText' => $legendText,
- 'headText' => $headText,
- 'subText' => $subText,
- 'extra' => $extra,
- 'primary_key' => $key
- );
- return $res;
-}
-
-/**
- * build the html for showing the tables to have in order to put current table in 2NF
- *
- * @param array $partialDependencies array containing all the dependencies
- * @param string $table current table
- *
- * @return string HTML
- */
-function PMA_getHtmlForNewTables2NF($partialDependencies,$table)
-{
- $html = '
' . sprintf(
- __(
- 'In order to put the '
- . 'original table \'%1$s\' into Second normal form we need '
- . 'to create the following tables:'
- ), htmlspecialchars($table)
- ) . '
'
- );
- $error = true;
- break;
- }
- }
- return array(
- 'legendText' => __('End of step'),
- 'headText' => $headText,
- 'queryError' => $error,
- 'extra' => $message
- );
-}
-
-/**
- * build the html for showing the new tables to have in order
- * to put given tables in 3NF
- *
- * @param object $dependencies containing all the dependencies
- * @param array $tables tables formed after 2NF and need to convert to 3NF
- * @param string $db current database
- *
- * @return array containing html and the list of new tables
- */
-function PMA_getHtmlForNewTables3NF($dependencies, $tables, $db)
-{
- $html = "";
- $i = 1;
- $newTables = array();
- foreach ($tables as $table=>$arrDependson) {
- if (count(array_unique($arrDependson)) == 1) {
- continue;
- }
- $primary = PhpMyAdmin\Index::getPrimary($table, $db);
- $primarycols = $primary->getColumns();
- $pk = array();
- foreach ($primarycols as $col) {
- $pk[] = $col->getName();
- }
- $html .= '
' . sprintf(
- __(
- 'In order to put the '
- . 'original table \'%1$s\' into Third normal form we need '
- . 'to create the following tables:'
- ), htmlspecialchars($table)
- ) . '