FrenchTech SAAS
33.5K views | +5 today
FrenchTech SAAS
Les news de l'univers SAAS et FrenchTech
Curated by Mickael Ruau
Your new post is loading...
Your new post is loading...

Popular Tags

Scooped by Mickael Ruau
August 26, 2013 9:45 AM
Scoop.it!

Howto generate meaningful test data using a MySQL function | MySQL

You can use this MySQL function to generate names, (e-mail)addresses, phone numbers, urls, bit values, colors, IP address, etc.. As usual, the code is provided in a zip and the code is fully documented.
Mickael Ruau's insight:

When creating random test data it is important that the data matches your domain values. Just a random string generated with a MD5 hash does not resemble real data and cannot be used for testing. There are some tools that you can buy to generate meaningful test data, but you can do this with a simple function in your database, free of charge

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:43 AM
Scoop.it!

MySQL stored procedures to manage hierarchical trees in a MySQL database | MySQL

Below you will find all code to create the table and the stored procedures to manage hierarchical trees in MySQL. All code is documented.
Mickael Ruau's insight:

The following stored procedures are provided:

tree_add_root()tree_add_node(id,name,label,description)tree_update_node(id,label,description)tree_get_all(depth,indentstring)tree_get_branch(id,depth,indentstring)tree_get_branch_by_name(parentname,name,depth,indentstring)tree_get_parents(id,indentstring)tree_swap_leafs(id1,id2)tree_del(id)

All code is documented and can be downloaded in a zip file.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:36 AM
Scoop.it!

Apache Xindice

Apache Xindice | FrenchTech SAAS | Scoop.it

Apache Xindice is a database designed from the ground up to store XML data or what is more commonly referred to as a native XML database.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:32 AM
Scoop.it!

Storing Hierarchical Data in a Database - SitePoint

Storing Hierarchical Data in a Database - SitePoint | FrenchTech SAAS | Scoop.it
Modified Preorder Tree Traversal Now, let’s have a look at another method for storing trees. Recursion can be slow, so we would rather not use a recursive function. We’d also like to minimize the number of database queries.
Mickael Ruau's insight:

We’ll start by laying out our tree in a horizontal way. Start at the root node (‘Food’), and write a 1 to its left. Follow the tree to ‘Fruit’ and write a 2 next to it. In this way, you walk (traverse) along the edges of the tree while writing a number on the left and right side of each node. The last number is written at the right side of the ‘Food’ node. In this image, you can see the whole numbered tree, and a few arrows to indicate the numbering order.

We’ll call these numbers left and right (e.g. the left value of ‘Food’ is 1, the right value is 18). As you can see, these numbers indicate the relationship between each node. Because ‘Red’ has the numbers 3 and 6, it is a descendant of the 1-18 ‘Food’ node. In the same way, we can say that all nodes with left values greater than 2 and right values less than 11, are descendants of 2-11 ‘Fruit’. The tree structure is now stored in the left and right values. This method of walking around the tree and counting nodes is called the ‘modified preorder tree traversal’ algorithm.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:27 AM
Scoop.it!

Mike Hillyer's Personal Webspace

Mike Hillyer's Personal Webspace | FrenchTech SAAS | Scoop.it

Most users at one time or another have dealt with hierarchical data in a SQL database and no doubt learned that the management of hierarchical data is not what a relational database is intended for. The tables of a relational database are not hierarchical (like XML), but are simply a flat list. Hierarchical data has a parent-child relationship that is not naturally represented in a relational database table.

Mickael Ruau's insight:

What I would like to focus on in this article is a different approach, commonly referred to as the Nested Set Model. In the Nested Set Model, we can look at our hierarchy in a new way, not as nodes and lines, but as nested containers.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:25 AM
Scoop.it!

Trees in SQL: Nested Sets and Materialized Path | BMC Communities

Trees in SQL: Nested Sets and Materialized Path | BMC Communities | FrenchTech SAAS | Scoop.it

In this article I'll investigate two out of four  well known approaches to accomplishing this and show a connection between them.  We'll discover a new method that could be considered as a "mix-in" between  materialized path and nested sets.

Mickael Ruau's insight:
Calculating Materialized Path and Distance between nodes

Strictly speaking, we don't have to use a materialized path, since our  encoding is an alternative. On the other hand, a materialized path provides a  much more intuitive visualization of the node position in the hierarchy, so that  we can use the materialized path for input and output of the data if we provide  the mapping to our model.

Implementation is a simple application of the methods from the previous  section. We print the sibling number, jump to the parent, then repeat the above  two steps until we reach the root:

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:20 AM
Scoop.it!

DB_NestedSet

DB_NestedSet let's you create trees with infinite depth
inside a relational database.

Mickael Ruau's insight:

The package provides a way to
o create/update/delete nodes
o query nodes, trees and subtrees
o copy (clone) nodes, trees and subtrees
o move nodes, trees and subtrees
o Works with PEAR::DB, PEAR::MDB, PEAR::MDB2
o output the tree with
- PEAR::HTML_TreeMenu
- TigraMenu (http://www.softcomplex.com/products/tigra_menu/)
- CoolMenus (http://www.dhtmlcentral.com/projects/coolmenus/)
- PEAR::Image_GraphViz (http://pear.php.net/package/Image_GraphViz)
- PEAR::HTML_Menu

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 6:13 AM
Scoop.it!

Bases de données relationnelles et normalisation : de la première à la sixième forme normale

Bases de données relationnelles et normalisation : de la première à la sixième forme normale | FrenchTech SAAS | Scoop.it
Bases de données relationnelles et normalisation : de la première à la sixième forme normale
No comment yet.
Scooped by Mickael Ruau
August 26, 2013 6:06 AM
Scoop.it!

Tutoriel de Bases de Données Relationnelles - Dépendances fonctionnelles et normalisation

Propriétés des dépendances fonctionnelles (ou axiomes d'Amstrong)DF1 : réflexivité  Y inclus-ou-egal X   =>   X -> YDF2 : augmentation X -> Y => X,Z -> Y,ZDF3 : transitivité X -> Y ET Y -> Z => X ->ZDF4 : pseudo-transitivité X -> Y ET Y,W -> Z => X,W -> ZDF5 : union X -> Y ET X -> Z => X -> Y,ZDF6 : décomposition X -> Y ET Y   Z => X -> Z
Mickael Ruau's insight:

Algorithme de décomposition :

entrée : un schéma relationnel (ensemble d'attributs) et un ensemble E de DF entre ses attributssortie : une ou plusieurs relations en 3FN dont la jointure redonne la relation initiale (par contre des DF de E ont pu être perdues)principe: l'algorithme peut se voir comme la construction d'un arbre binaire. La racine de cet arbre est la relation à décomposer. L'arbre se construit récursivement de la manière suivante :on choisit une DF dfi dans l'ensemble E des DFle fils gauche du noeud racine est une relation composé de tous les attributs de dfidfi est retirée de l'ensemble Ele fils droit du noeud racine est une relation composée de tous les attibuts de la racine excepté ceux présents en partie droite de dfi

Problèmes : la solution dépend du choix des DF selon lesquelles on choisit de décomposer et il ne préserve pas nécessairement les DF.

On sait néanmoins que toute relation admet une décomposition en 3FN qui préserve les DF. 

Il existe un algorithme dit de synthèse qui permet d'obtenir une décomposition 3FN qui préserve les DF. Il est basé sur le calcul de la couverture minimale (ou irredondante) d'un ensemble de DF.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 6:02 AM
Scoop.it!

Algorithme de décomposition FNBC (SPI)

Soit un schéma de relation R, et une couverture minimale F' de dépendances fonctionnelles s'appliquant sur R. Une décomposition SPI de R, qu'on appellera D, est construite de manière itérative :

D est initialisée à R,Soit T une relation de D qui ne soit pas FNBC. Cela signifie qu'il y a une dépendance fonctionnelle X -> A s'appliquant sur T telle que X n'est pas clé de T, et que A n'est pas un sous-ensemble de X. On décompose alors T en T1 contenant A et les attributs de X, et T2 contenant tous les attributs de T sauf A,D est réinitialisée avec T1 et T2, et on boucle sur b) jusqu'à ce que toutes les relations soient FNBC.
No comment yet.
Scooped by Mickael Ruau
August 26, 2013 6:01 AM
Scoop.it!

Décomposition préservant les dépendances (SPD)

Soit un schéma de décomposition T = {R1, R2, …, Rk}, et un ensemble F de dépendances fonctionnelles.

Soit P Z (F) l'ensemble des dépendances fonctionnelles {X -> Y} appartenant à F+ (fermeture de F), et tel que XY Í Z.

On dit que T préserve les dépendances fonctionnelles si P R1 (F) ÈP R2 (F) … ÈP Rk (F) permet de retrouver l'ensemble F d'origine.

Mickael Ruau's insight:

Remarque : cette contrainte est importante car elle signifie lorsqu'elle est vérifiée que les contraintes d'intégrité de la relation R seront conservées avec la décomposition.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 5:59 AM
Scoop.it!

Axiomes d'Armstrong et couverture minimale

La fermeture d'un ensemble d'attributs X, notée (X)+, représente l'ensemble des attributs de R qui peuvent être déduits de X à partir d'une famille de dépendances fonctionnelles en appliquant les axiomes d'Armstrong. Ainsi, Y sera inclus dans (X)+ ssi X -> Y.

Mickael Ruau's insight:

Algorithme de calcul de la couverture minimale :

écrire toutes les dépendances fonctionnelles de F sous la forme X -> A, où X est un groupe d'attributs de R, et A un attribut élémentaire. Les dépendances fonctionnelles du type X -> A1 A2 … An sont remplacées par n dépendances fonctionnelles X -> Ai.essayer de supprimer des dépendances fonctionnelles en utilisant la notion de fermeture d'un ensemble d'attributs, (X)+.

 

 

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 5:51 AM
Scoop.it!

Forme normale (bases de données relationnelles) - Wikipédia

Dans une base de données relationnelle, une forme normale désigne un type de relation particulier entre les entités.

Le but essentiel de la normalisation est d'éviter les anomalies transactionnelles pouvant découler d'une mauvaise modélisation des données et ainsi éviter un certain nombre de problèmes potentiels tels que les anomalies de lecture, les anomalies d'écriture, la redondance des données et la contre-performance.

La normalisation des modèles de données permet de vérifier la robustesse de leur conception pour améliorer la modélisation (et donc obtenir une meilleure représentation) et faciliter la mémorisation des données en évitant la redondance et les problèmes sous-jacents de mise à jour ou de cohérence. La normalisation s’applique à toutes les entités et aux relations porteuses de propriétés.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:44 AM
Scoop.it!

Use the strict sql mode when compiling a MySQL stored procedure to avoid unexpected errors. | MySQL

Setting the mode to STRICT_ALL_TABLES when you compile your stored procedure or function can prevent a lot of subtle bugs in your MySQL application. See how to prevent it.
No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:39 AM
Scoop.it!

MySQL :: Managing Hierarchical Data in MySQL

MySQL :: Managing Hierarchical Data in MySQL | FrenchTech SAAS | Scoop.it

Most users at one time or another have dealt with hierarchical data in a SQL database and no doubt learned that the management of hierarchical data is not what a relational database is intended for. The tables of a relational database are not hierarchical (like XML), but are simply a flat list. Hierarchical data has a parent-child relationship that is not naturally represented in a relational database table.

F

Mickael Ruau's insight:

The book covers advanced topics which I have not covered in this article, and provides additional methods for managing hierarchical data in addition to the Adjacency List and Nested Set models.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:35 AM
Scoop.it!

Trees in SQL

This set-oriented method for representing trees in SQL runs orders of magnitude faster than the adjacency list method.
No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:29 AM
Scoop.it!

Storing Hierarchical Data in a Database - SitePoint

Storing Hierarchical Data in a Database - SitePoint | FrenchTech SAAS | Scoop.it
Whether you want to build your own forum, publish the messages from a mailing list on your Website, or write your own CMS: there will be a moment that you'll want to store hierarchical data in a database.
Mickael Ruau's insight:

Cette première page explore la technique de l'association récursive et ses défauts.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:26 AM
Scoop.it!

PHP Tutorials Examples Managing Hierarchical Data with PHP and MySQL

PHP Tutorials Examples Managing Hierarchical Data with PHP and MySQL | FrenchTech SAAS | Scoop.it
Getting Started

To help guide us through this tutorial we will be using a MySQL database with two tables, categories and products. The SQL dump is provided here. The name of the database is "hierachy".

Mickael Ruau's insight:

This tutorial follows on from the work of Mike Hillyer of MySQL AB. His original tutorial can be found at http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:21 AM
Scoop.it!

Four ways to work with hierarchical data | evolt.org

Four ways to work with hierarchical data | evolt.org | FrenchTech SAAS | Scoop.it
A world community for web developers, evolt.org promotes the mutual free exchange of ideas, skills and experiences.
Mickael Ruau's insight:
RecursionStackFlat TableModified Preorder Tree Traversal Algorithm
No comment yet.
Scooped by Mickael Ruau
August 26, 2013 9:18 AM
Scoop.it!

SQL Oracle : requêtes avancées

Gestion des hiérarchies

Mickael Ruau's insight:

SELECT liste_col
FROM nom de table
[WHERE nom colonne|constante|expression opérateur nom colonne|constante|expression]
CONNECT BY PRIOR expression = expression [and|or nom colonne|constante|expression
opérateur de comparaison nom colonne|constante|expression]
START WITH nom colonne|constante|expression opérateur nom colonne|constante|expression]
[ORDER BYexpression]


PRIOR indique si l'arbre doit être parcouru de la racine vers les feuilles ou des feuilles vers la racine. Il précède l'enfant si on parcourt l'arbre de la racine vers les feuilles. Il précède la clé étrangère (le parent) si on parcourt l'arbre des feuilles vers la racine. Une restriction dans une clause supprime les individus, mais par leur descendance (ou leur ascendance suivant le sens du parcours).  
Une restriction dans une clause CONNECT BY supprime les individus et leur descendance (ou leur ascendance suivant le sens du parcours).
START WITH indique le noeud à partir duquel l'arbre est parcouru. Un select avec gestion d'arborescence ne peut être une jointure. ORDER BY est exécuté après le tri arborescent.

Exemples
arborescence complète chef vers subordonné
SELECT e.ename  Organigramme
FROM emp E
START WITHe.mgr IS NULL
connect by E.MGR = prior E.EMPNO;

arborescence complète chef vers subordonné
Select lpad(E.ENAME,LENGTH(E.ENAME)+(LEVEL-1)*3,'+') "Organigramme horizontal"
from EMP E
where E.ENAME <> 'BLAKE'
start with E.MGR is null
connect by E.MGR = prior E.EMPNO; nous donne :

Organigramme horizontal
-----------------------
KING
+++JONES
++++++SCOTT
+++++++++ADAMS
++++++FORD
+++++++++SMITH
++++++ALLEN
++++++WARD
++++++MARTIN
++++++TURNER
++++++JAMES
+++CLARK
++++++MILLER

13 ligne(s) sélectionnée(s).
arborescence partielle du subordonné vers le chef

Select lpad(E.ENAME,LENGTH(E.ENAME)+(LEVEL-1)*3,'+') "Organigramme horizontal"
from EMP E
start with E.ENAME = 'ADAMS'
connect by E.EMPNO = prior E.MGR; nous donne :

Organigramme horizontal
-----------------------
ADAMS
+++SCOTT
++++++JONES
+++++++++KING

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 6:10 AM
Scoop.it!

Tutoriel de Bases de Données Relationnelles - Langages relationnels

Règles de passage de l'algèbre relationnelle vers SQL
Mickael Ruau's insight:

Soient R(X) et S(Y) deux relations de schémas distincts, T(V,W), U(W,Z) deux relations ayant un ensemble d'attributs communs, Q1(X), Q2(X) deux relations de même schéma et P(W).

sélectionSELECTION condition (R)select *from R
where conditionprojectionPROJECTION A1, ..., An (R)select distinct A1, ..., An
from Ropérateurs ensemblistes

Q1 UNION Q2, Q1
Q1 INTERSECTION Q2
Q1 - Q2

select * from Q1
union, intersect, minus
select * from Q2

jointureT * Uselect V, W, Z
from T, U where T.W=U.W (en réalité égalité sur tous les attributs communs)produit cartésienR X S

select R.*, S.*
from R, S

théta-jointureR* (condition) Sselect X, Y
from R, S
where conditiondivision

T / P

avec P partie de T

select V
from T
group by V
having count(distinct W) >= (select count(distinct W) from P)
No comment yet.
Scooped by Mickael Ruau
August 26, 2013 6:02 AM
Scoop.it!

Algorithme de décomposition FN3 (SPI et préservant les DF)

Soit un schéma de relation R, et une couverture minimale F' de dépendances fonctionnelles s'appliquant sur R. Une décomposition SPI et SPD de R, qu'on appellera D, est construite de la façon suivante :

pour chaque dépendance fonctionnelle X -> A, on crée une relation Ri (X, A),si on a plusieurs dépendances fonctionnelles telles que X -> A1, X -> A2, …, X -> An, alors on regroupe tous ces attributs dans une même relation Rj (X, A1, A2, …, An),les attributs n'apparaissant dans aucune relation (pas présents dans les dépendances fonctionnelles) sont regroupés dans une même relation,pour avoir une décomposition SPI, il faut s'assurer qu'il y ait au-moins une clé de R dans une des relations de décomposition. Si ce n'est pas le cas, il faut soit ajouter une relation contenant une clé de R, soit ajouter des attributs dans une des relations de décomposition afin de satisfaire cette contrainte.
No comment yet.
Scooped by Mickael Ruau
August 26, 2013 6:01 AM
Scoop.it!

Dépendances fonctionnelles

Définition : un attribut (ou un groupe d'attributs) B est dit "fonctionnellement dépendant" d'un attribut (ou d'un groupe d'attributs) A si :

a1 = a2 => b1 = b2,

a1, a2, b1, b2 étant des réalisations (valeurs) des attributs A et B dans des n-uplets de la base de données.

On dit alors que A "détermine" B, et on note A -> B.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 6:00 AM
Scoop.it!

Décomposition dans perte d'information (SPI)

La décomposition de R est dite SPI "sous F" si :

" r satisfaisant F, r = P R1 (r) jointure P R2 (r) … jointure P Rk (r)

Mickael Ruau's insight:

La "méthode des tableaux" permet de vérifier qu'une décomposition se fait sans perte d'information. Elle comprend trois phases :

on construit un tableau avec autant de colonnes que d'attributs Aj, et autant de lignes que de schémas de décomposition Ri,on effectue un remplissage initial du tableau qui correspond à la décomposition envisagée, et on procède de la façon suivante : à l'intersection de la ligne i et de la colonne j, on met aj si l'attribut Aj appartient au schéma de relation Ri, bij sinon,pour chaque dépendance fonctionnelle X -> Y appartenant à F, on cherche des lignes du tableau pour lesquelles les éléments correspondant à tous les attributs de X sont égaux. Si c'est le cas, on égalise les éléments de ces lignes pour les attributs de Y :si au-moins un des éléments correspondant à Y est égal à aj, alors tous les autres sont égalisés à aj, sinon, les éléments sont égalisés à bij.

En fin de parcours, si une des lignes est remplie de a, alors la décomposition est SPI.

No comment yet.
Scooped by Mickael Ruau
August 26, 2013 5:57 AM
Scoop.it!

Bases de données : Théorie et modélisation

ACID vs BASE
Mickael Ruau's insight:

Le concept ACID fonctionne très bien pour les bases de données relationnelles qui répondent aux objectifs précédemment cités.

 

Cependant, avec le développement du Cloud computing et des systèmes distribués, de nouvelles bases de données ont été conçues pour répondre à des contraintes différentes.

Un nouveau concept opposé à ACID est apparu, le concept BASE :

- Basic Availability : le sytème doit toujours être accessible.

- Soft state : l'état de la base de données n'est pas garanti à un instant t.

- Eventually Consistent : la cohérence des données à un instant t n'est pas primordiale.

No comment yet.