Storing Essays In Mysql

Storing Essays In Mysql-24
In a real-world application, we have to deal with untranslated texts.Usually, we use some default language in the place of them.Other databases Other database systems such as Oracle or Postgre SQL do not have support for a collation definition in each column and use a different approach for a language-dependent sorting.

In a real-world application, we have to deal with untranslated texts.Usually, we use some default language in the place of them.Other databases Other database systems such as Oracle or Postgre SQL do not have support for a collation definition in each column and use a different approach for a language-dependent sorting.

Multilingual applications use two types of texts requiring translation.

The first ones are messages without a relation to the data (for example the title "Contents") which can easily be translated by GNU gettext or by a simple database table.

Multilingual applications should use simple SQL queries (to avoid bugs), keep the performance high (which mainly means to utilize indexes) and produce the exact output (sort according to each language collation and respect the fulltext threshold).

In additionally database consistency should be maintained, for example to preserve uniqueness of URLs.

Therefore, in a single language environment, the table would look like this: CREATE TABLE `product` ( `product_id` int(11) NOT NULL auto_increment, `group_id` int(11) NOT NULL, `name` varchar(50) NOT NULL, `url` varchar(50) NOT NULL, `price` decimal(9, 2) NOT NULL, `description` text NOT NULL, UNIQUE KEY `url` (`url`), KEY `group_id` (`group_id`, `name`), FULLTEXT KEY `name` (`name`, `description`), PRIMARY KEY (`product_id`) ); CREATE TABLE `language` ( `language_id` char(2) NOT NULL, `collation` varchar(64) NOT NULL, PRIMARY KEY (`language_id`) ); CREATE TABLE `product` ( `product_id` int(11) NOT NULL auto_increment, `group_id` int(11) NOT NULL, `price` decimal(9, 2) NOT NULL, KEY `group_id` (`group_id`), PRIMARY KEY (`product_id`) ); CREATE TABLE `product_translation` ( `product_id` int(11) NOT NULL, `language_id` char(2) NOT NULL, `name` varchar(50) NOT NULL, `url` varchar(50) NOT NULL, `description` tinytext NOT NULL, UNIQUE KEY `language_id_2` (`language_id`, `url`), KEY `language_id` (`language_id`, `name`), FULLTEXT KEY `name` (`name`, `description`), FOREIGN KEY (`language_id`) REFERENCES `language` (`language_id`), FOREIGN KEY (`product_id`) REFERENCES `product` (`product_id`), PRIMARY KEY (`product_id`, `language_id`) ); " SELECT `product_translation`.`url`, `product_translation`.`name`, `product`.`price` FROM `product` INNER JOIN `product_translation` USING (`product_id`) WHERE `product`.`group_id` = $group_id AND `product_translation`.`language_id` = '$language_id' ORDER BY `product_translation`.`name` COLLATE $collation LIMIT 30 " for sorting at all because we need a different collation for every language. My SQL natural language search ignores words occurring in at least half of the rows.

Because all languages are mixed in one column, this feature will likely exclude most words and thus be useless.With this table schema, we have two options available to solve this problem: CREATE TABLE `language` ( `language_id` char(2) NOT NULL, `collation` varchar(64) NOT NULL, PRIMARY KEY (`language_id`) ); CREATE TABLE `product` ( `product_id` int(11) NOT NULL auto_increment, PRIMARY KEY (`product_id`) ); CREATE TABLE `product_translation` ( `product_id` int(11) NOT NULL, `language_id` char(2) NOT NULL, `group_id` int(11) NOT NULL, `name` varchar(50) NOT NULL, `url` varchar(50) NOT NULL, `price` decimal(9, 2) NOT NULL, `description` text NOT NULL, UNIQUE KEY `language_id_2` (`language_id`, `url`), KEY `language_id` (`language_id`, `group_id`, `name`), FULLTEXT KEY `name` (`name`, `description`), FOREIGN KEY (`product_id`) REFERENCES `product` (`product_id`), FOREIGN KEY (`language_id`) REFERENCES `language` (`language_id`), PRIMARY KEY (`product_id`, `language_id`) ); (The product table can be just a sequence.) The group identifier and the price are copied to all languages.Technically a trigger can achieve it, however we have to define a trigger on all translatable tables in the database and it has to respect all columns in the table (so addition or modification of a table would be difficult).Adding a language definitely will be a difficult operation so we do not need to solve the dilemma whether to store the default language to untranslated texts.It can be stored to keep query simplicity and speed. Adding a new language will be a complex operation when this approach is used.Another approach would be to store each language in a separate table and copy common columns the same way as we did in the Data copy approach.This however involves problems with trigger maintenance.Unique index would not work in the case of falling back to the default language or we would have to do all modifications in a transaction when copying the default language.The previous approaches have one basic problem - they are storing different data (texts with miscellaneous collations) to the same column.The database systems can use this function together with partial function indexes to sort the products effectively in the Data copy schema.However, we still have to define the indexes at the time of adding a language.

SHOW COMMENTS

Comments Storing Essays In Mysql

The Latest from gbo33.ru ©