Done: relations 1:1 normalization
Esse commit está contido em:
@@ -16,6 +16,7 @@
|
||||
private $focus = null;
|
||||
private $rel = null;
|
||||
public $opposite = null;
|
||||
public $uniqueRef = false;
|
||||
public $treated = false; //to be used by Normalizer
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ class Analyst {
|
||||
* @param MindEntity $en
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isItWorthMergin(MindEntity $en)
|
||||
public static function isItWorthMerging(MindEntity $en)
|
||||
{
|
||||
GLOBAL $_MIND;
|
||||
if(Normalizer::relevanceAmount($en) < $_MIND->conf['merging_amount_pts'])
|
||||
@@ -86,7 +86,7 @@ class Analyst {
|
||||
foreach(self::$entities as $k=>$entity)
|
||||
{
|
||||
if($detailed)
|
||||
echo " (".$entity->relevance.")".$entity->name.'-'.$k."\n";
|
||||
echo " (".$entity->relevance.")".$entity->name."\n";
|
||||
foreach($entity->properties as $prop)
|
||||
{
|
||||
$props++;
|
||||
|
||||
@@ -51,6 +51,18 @@ abstract class Normal {
|
||||
return $focus;
|
||||
}
|
||||
|
||||
public static function fixOneByOneRelation(MindEntity &$focus,
|
||||
MindEntity &$rel,
|
||||
MindRelation &$relation)
|
||||
{
|
||||
/*
|
||||
* excluir a relação entre a mais forte e a mais fraca
|
||||
* marcar a fk como pk
|
||||
*/
|
||||
//Analyst::unsetRelation(Analyst::$relations[$focus->rel.PROPERTY_SEPARATOR.$focus->name]);
|
||||
//Analyst::$relations[$rel->name.PROPERTY_SEPARATOR.$focus->name]->uniqueRef= true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pontuation amount for the relevance an entity may have.
|
||||
* It takes many directrizes to define how relevant an entity is.
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes the 1:1 relationsm normalizing it
|
||||
* Fixes the 1:1 relations, normalizing them
|
||||
*/
|
||||
public static function fixOneByOneRel()
|
||||
{
|
||||
@@ -65,15 +65,17 @@
|
||||
}elseif($rel->min== 0 && $rel->opposite->min == 0)
|
||||
{
|
||||
// for 0:1 / 0:1 relations
|
||||
if(Analyst::isItWorthMergin(self::$predicate))
|
||||
{
|
||||
if(Analyst::isItWorthMerging(self::$predicate))
|
||||
self::mergeEntities(self::$focus, self::$predicate, $rel);
|
||||
}else{
|
||||
// TODO: fix entities in 1:1
|
||||
}
|
||||
else
|
||||
self::fixOneByOneRelation(self::$focus,
|
||||
self::$predicate,
|
||||
$rel);
|
||||
}else{
|
||||
// for 0:1 / 1:1 relations
|
||||
// TODO: fix entities in 1:1
|
||||
self::fixOneByOneRelation(self::$focus,
|
||||
self::$predicate,
|
||||
$rel);
|
||||
}
|
||||
}while($rel= next(self::$oneByOne));
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ class Tokenizer extends Token{
|
||||
public static function loadTypes($xml)
|
||||
{
|
||||
self::$dataTypes['varchar'] = self::parseByComa($xml->varchar);
|
||||
self::$dataTypes['text'] = self::parseByComa($xml->text);
|
||||
self::$dataTypes['char'] = self::parseByComa($xml->char);
|
||||
self::$dataTypes['int'] = self::parseByComa($xml->int);
|
||||
self::$dataTypes['float'] = self::parseByComa($xml->float);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
-->
|
||||
<root>
|
||||
<varchar>string,characters,chars,varchar,description,desc,obs,observation</varchar>
|
||||
<text>text,desc,description,obs,observation</text>
|
||||
<char>char,character,c,letter,digit</char>
|
||||
<int>int,integer,number</int>
|
||||
<float>float,real,double,money,percentage,perc,precision</float>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
-->
|
||||
<root>
|
||||
<varchar>string,characteres,varchar,descrição,desc,obs</varchar>
|
||||
<text>text,texto,obs,observação,desc,descrição</text>
|
||||
<char>char,caracter,caractere,letra,digito</char>
|
||||
<int>int,integer,inteiro,dígito,número</int>
|
||||
<float>float,real,double,dinheiro,percentagem,perc,porcentagem,precisão</float>
|
||||
|
||||
externo
+7
-1
@@ -25,4 +25,10 @@ ask_about_doubts=on
|
||||
show_decisions=on
|
||||
show_tips=on
|
||||
; you can also enable the use of plugins
|
||||
plugins=on
|
||||
plugins=on
|
||||
; default identifier of primary key properties
|
||||
pk_prefix="pk_"
|
||||
; add the pk_prefix to properties that were defined as key, manuyally?
|
||||
add_pk_prefix_to_all_keys=on
|
||||
; default identifier of foreign key properties
|
||||
fk_prefix="fk_"
|
||||
externo
+1
-1
@@ -16,4 +16,4 @@ relations_length= 4
|
||||
; should use the entity's name as prefix on merged entities
|
||||
use_prefix_on_merged_entities= true
|
||||
; how many points should consider an entity worth of mergin or not
|
||||
merging_amount_pts=3
|
||||
merging_amount_pts=2
|
||||
@@ -1,9 +1,9 @@
|
||||
pessoa tem 1 ou um registro e cada registro tem 1 ou uma pessoa.
|
||||
pessoa tem nenhum ou um registro e cada registro tem nenhuma ou uma pessoa.
|
||||
pessoa pode ter vários clientes, mentores e fornecedores.
|
||||
registro tem muitos endereços.
|
||||
|
||||
pessoa tem nome:varchar(260), idade:int e sexo:char(1), sendo que registro terá
|
||||
código do cadastro:int e descrição:varchar(600).
|
||||
código do cadastro:int, observação:text, descrição:varchar(600).
|
||||
|
||||
/*
|
||||
armamento tem número de série:int(20, único), id:int(), peso do equipamento:int().
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário