http://silico.biotoul.fr/site/index.php?title=L2-L3_Bioinfo_-_TD_Bases_de_donnees_-_correction&feed=atom&action=historyL2-L3 Bioinfo - TD Bases de donnees - correction - Revision history2024-03-28T14:01:38ZRevision history for this page on the wikiMediaWiki 1.15.1http://silico.biotoul.fr/site/index.php?title=L2-L3_Bioinfo_-_TD_Bases_de_donnees_-_correction&diff=3543&oldid=prevBarriot at 16:20, 20 February 20172017-02-20T16:20:22Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 16:20, 20 February 2017</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"><!-- </del>= Contexte =</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>= Contexte =</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* sensisibilté/résistances d'écotypes différents d'''Araidopsis thaliana'' (arabette) à une bactérie pathogène.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* sensisibilté/résistances d'écotypes différents d'''Araidopsis thaliana'' (arabette) à une bactérie pathogène.</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 337:</td>
<td colspan="2" class="diff-lineno">Line 337:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>WHERE Accession_id='patient_0';</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>WHERE Accession_id='patient_0';</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></source></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></source></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">--></del></div></td><td colspan="2"> </td></tr>
<!-- diff generator: internal 2024-03-28 14:01:38 -->
</table>Barriothttp://silico.biotoul.fr/site/index.php?title=L2-L3_Bioinfo_-_TD_Bases_de_donnees_-_correction&diff=3517&oldid=prevBarriot at 14:53, 20 February 20172017-02-20T14:53:10Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 14:53, 20 February 2017</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"><!-- </ins>= Contexte =</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>= Contexte =</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* sensisibilté/résistances d'écotypes différents d'''Araidopsis thaliana'' (arabette) à une bactérie pathogène.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* sensisibilté/résistances d'écotypes différents d'''Araidopsis thaliana'' (arabette) à une bactérie pathogène.</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 338:</td>
<td colspan="2" class="diff-lineno">Line 337:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>WHERE Accession_id='patient_0';</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>WHERE Accession_id='patient_0';</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></source></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></source></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">--></ins></div></td></tr>
<!-- diff generator: internal 2024-03-28 14:01:38 -->
</table>Barriothttp://silico.biotoul.fr/site/index.php?title=L2-L3_Bioinfo_-_TD_Bases_de_donnees_-_correction&diff=3501&oldid=prevBarriot at 14:07, 20 February 20172017-02-20T14:07:47Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 14:07, 20 February 2017</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"><!-- </del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Contexte =</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Contexte =</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 338:</td>
<td colspan="2" class="diff-lineno">Line 338:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>WHERE Accession_id='patient_0';</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>WHERE Accession_id='patient_0';</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></source></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></source></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">--></del></div></td><td colspan="2"> </td></tr>
<!-- diff generator: internal 2024-03-28 14:01:38 -->
</table>Barriothttp://silico.biotoul.fr/site/index.php?title=L2-L3_Bioinfo_-_TD_Bases_de_donnees_-_correction&diff=3496&oldid=prevBarriot at 13:22, 20 February 20172017-02-20T13:22:01Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 13:22, 20 February 2017</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline"><!-- </ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Contexte =</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Contexte =</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 338:</td>
<td colspan="2" class="diff-lineno">Line 338:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>WHERE Accession_id='patient_0';</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>WHERE Accession_id='patient_0';</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></source></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div></source></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">--></ins></div></td></tr>
<!-- diff generator: internal 2024-03-28 14:01:38 -->
</table>Barriothttp://silico.biotoul.fr/site/index.php?title=L2-L3_Bioinfo_-_TD_Bases_de_donnees_-_correction&diff=3373&oldid=prevBarriot: /* Utilisation de la base de données */2017-02-07T14:16:36Z<p><span class="autocomment">Utilisation de la base de données</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 14:16, 7 February 2017</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 33:</td>
<td colspan="2" class="diff-lineno">Line 33:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Utilisation de la base de données =</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Utilisation de la base de données =</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">* Base de données MySQL [[Media:L2-L3 Bioinfo - DB Backup.sql]]</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>== Consultation ==</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>== Consultation ==</div></td></tr>
<!-- diff generator: internal 2024-03-28 14:01:38 -->
</table>Barriothttp://silico.biotoul.fr/site/index.php?title=L2-L3_Bioinfo_-_TD_Bases_de_donnees_-_correction&diff=3372&oldid=prevBarriot at 14:16, 7 February 20172017-02-07T14:16:01Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 14:16, 7 February 2017</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">[[Category:Teaching]]</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div> </div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Contexte =</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Contexte =</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<!-- diff generator: internal 2024-03-28 14:01:38 -->
</table>Barriothttp://silico.biotoul.fr/site/index.php?title=L2-L3_Bioinfo_-_TD_Bases_de_donnees_-_correction&diff=3371&oldid=prevBarriot: Created page with 'Category:Teaching = Contexte = * sensisibilté/résistances d'écotypes différents d'''Araidopsis thaliana'' (arabette) à une bactérie pathogène. * photos et mesures de …'2017-02-07T14:15:47Z<p>Created page with '<a href="/site/index.php?title=Category:Teaching&action=edit&redlink=1" class="new" title="Category:Teaching (page does not exist)">Category:Teaching</a> = Contexte = * sensisibilté/résistances d'écotypes différents d'''Araidopsis thaliana'' (arabette) à une bactérie pathogène. * photos et mesures de …'</p>
<p><b>New page</b></p><div>[[Category:Teaching]]<br />
= Contexte =<br />
<br />
* sensisibilté/résistances d'écotypes différents d'''Araidopsis thaliana'' (arabette) à une bactérie pathogène.<br />
* photos et mesures de la surface foliaires de différents écotypes<br />
* par la suite, on va chercher à analyser la croissance des plantes, et donc leur sensibilité, par rapport aux génotypes<br />
* stockage de tout ça dans une base de données pour leur analyse statistique par la suite<br />
* en plus de la surface foliaire, il faut donc aussi stocker des informations sur les différents écotypes, les mesures effectuées et des informations sur les génotypes<br />
<br />
Au niveaux des '''écotypes''', afin de les différencier, à chaque écotype est attribué un '''identifiant unique''' (<tt>Accession_id</tt>) permettant de renseigner le '''pays d'origine''' (<tt>Country</tt>) avec la '''<tt>Latitude</tt>''' et la '''<tt>Longitude</tt>''' exactes ainsi que si la '''bactérie pathogène est naturellement présente''' (<tt>Natural_Bacterial_occurence</tt>).<br />
Concernant les images analysées à la 1ère séance de TP, il faut renseigner '''à quel écotype chaque image correspond''', '''quand''' a été prise l'image et éventuellement pouvoir ajouter des '''commentaires'''. <br />
Ensuite, avec les analyses effectuées, on souhaite également enregistrer la '''surface foliaire mesurée''', et '''par qui'''. Il faudra donc aussi conserver des informations sur les '''utilisateurs''' telles que leur '''identifiant''', leur '''nom''' et leur '''prénom''', leur '''provenance''' (L2/L3 BCP/2B2M/BOPE) et leur '''groupe de TP'''. Une autre mesure déjà effectuée sera stocker aussi : le nombre de '''racines latérales'''.<br />
Aux niveau des génotypes, on considère un certain nombre de marqueurs :<br />
* présence ou absence des gènes ou loci At1g01120, At3g26230, At5g46330 et RetroTranp_T1 dans le génome,<br />
* la valeur des marqueurs de type [[wikipedia:Single-nucleotide_polymorphism|SNP]] (''Single Nucleotide Polymophism'') pouvant être G, A , T ou C : SNP1 à SNP4<br />
* le nombre de répétitions de marqueurs de type [[wikipedia:Microsatellite|SSR]] (''Simple Sequence Repeat'') : SSR1 et SSR2<br />
<br />
= Modèle entités-associations =<br />
<br />
Dans un premier temps, proposez un modèle entités-associations modélisant les données à gérées.<br />
<br />
Pour cela, il vous faudra identifier les entités (ex: écotype) et leurs attributs. Et en parallèle, les relations/associations entre ces entités avec leurs attributs et la cardinalité des associations (ex: plusieurs images peuvent correspondre au même écotype).<br />
<br />
[[Image:L2-L3 Bioinfo - EA Model.png]]<br />
<br />
= Modèle relationnel =<br />
<br />
A partir du modèle précédent, il s'agit maintenant de le traduire en modèle relationnel ou schéma de bases de données.<br />
<br />
Il faudra donc définir les différentes tables avec leurs colonnes et le type de chaque colonne, ainsi que les attributs constituants les clés primaires (valeur unique dans une table) et les clés étrangères (attributs référençant d'autres lignes dans une table).<br />
<br />
[[Image:L2-L3 Bioinfo - DB Schema.png]]<br />
<br />
= Utilisation de la base de données =<br />
<br />
* Base de données MySQL [[Media:L2-L3 Bioinfo - DB Backup.sql]]<br />
<br />
== Consultation ==<br />
<br />
'''Sélection (des lignes et/ou des colonnes), tri, regroupement et sélection après regroupement :'''<br />
<br />
* Afficher tous les utilisateurs.<br />
<source lang='SQL'><br />
SELECT * FROM users;<br />
</source><br />
<br />
* Afficher tous les utilisateurs la même provenance que vous (ex: L2 BCP).<br />
<source lang='SQL'><br />
SELECT * FROM users WHERE type='TEACHER';<br />
</source><br />
<br />
<br />
* Afficher tous les identifiants, noms et prénoms des utilisateurs de la même provenance que vous.<br />
<source lang='SQL'><br />
SELECT User_id, firstname, name FROM users WHERE type='TEACHER';<br />
</source><br />
<br />
* La même chose mais en triant les résultats par nom.<br />
<source lang='SQL'><br />
SELECT User_id, firstname, name FROM users WHERE type='TEACHER' ORDER BY name;<br />
</source><br />
<br />
* Afficher tous les utilisateurs provenant de L2 triés par nom.<br />
<source lang='SQL'><br />
SELECT User_id, firstname, name, type FROM users WHERE type LIKE 'L2%' ORDER BY name;<br />
</source><br />
<br />
<br />
* La même chose mais triés par provenance puis par nom.<br />
<source lang='SQL'><br />
SELECT User_id, firstname, name, type FROM users WHERE type LIKE 'L2%' ORDER BY type, name;<br />
</source><br />
<br />
<br />
* Afficher les surfaces foliaires mesurées sur les images triés par surface décroissante.<br />
<source lang='SQL'><br />
SELECT * FROM measures WHERE Measure='Leaf_area';<br />
</source><br />
<br />
<br />
* Quels sont le minimum, la moyenne et le maximum de surface foliaire ?<br />
<source lang='SQL'><br />
SELECT min(Value), avg(Value), max(Value) FROM measures WHERE Measure='Leaf_area';<br />
</source><br />
<br />
<br />
<br />
* Combien y a-t-il d'utilisateurs dans la table ?<br />
<source lang='SQL'><br />
SELECT COUNT(*) FROM users;<br />
</source><br />
<br />
<br />
* Combien y a-t-il d'utilisateurs par provenance ?<br />
<source lang='SQL'><br />
SELECT type, COUNT(*) FROM users GROUP BY type;<br />
</source><br />
<br />
<br />
* La même chose trié par effectifs décroissant.<br />
<source lang='SQL'><br />
SELECT type, COUNT(*) as effectifs FROM users GROUP BY type ORDER BY effectifs DESC; <br />
SELECT type, COUNT(*) as effectifs FROM users GROUP BY type ORDER BY 2 DESC;<br />
</source><br />
<br />
<br />
* La même chose ayant au moins 10 utilisateur<br />
<source lang='SQL'><br />
SELECT type, COUNT(*) as effectifs FROM users GROUP BY type HAVING effectifs>9 ORDER BY effectifs DESC;<br />
</source><br />
<br />
<br />
Pour chez soi : <br />
* combien y a-t-il d'écotypes en tout ou par pays ? puis trié de manière décroissante ; puis, ayant au moins 5 écotypes dans le même pays.<br />
<source lang='SQL'> <br />
SELECT * FROM ecotype;<br />
SELECT Country, COUNT(*) as nb FROM ecotype GROUP BY Country;<br />
SELECT Country, COUNT(*) as nb FROM ecotype GROUP BY Country ORDER BY 2 DESC;<br />
SELECT Country, COUNT(*) as nb FROM ecotype GROUP BY Country HAVING nb>=5 ORDER BY 2 DESC;<br />
</source><br />
<br />
<br />
<br />
'''Jointure avec produit cartésien'''<br />
<table><br />
<tr><br />
<td><br />
T<br />
<table border=1 cellspacing=0 cellpadding=3><br />
<tr><br />
<th>Tid</th><br />
<th>Tcol2</th><br />
</tr><br />
<tr><br />
<td>1</td><br />
<td>a</td><br />
</tr><br />
<tr><br />
<td>1<br></td><br />
<td>b<br></td><br />
</tr><br />
<tr><br />
<td>2</td><br />
<td>c<br></td><br />
</tr><br />
</table> <br />
</td><td><br />
<math>\times</math><br />
</td><td><br />
U<br />
<table border=1 cellspacing=0 cellpadding=3><br />
<tr><br />
<th>Uid</th><br />
<th>Ucol2</th><br />
</tr><br />
<tr><br />
<td>1</td><br />
<td>X</td><br />
</tr><br />
<tr><br />
<td>2<br></td><br />
<td>Y<br></td><br />
</tr><br />
</table><br />
</td><td><br />
=<br />
</td><td><br />
T <math>\times</math> U<br />
<table border=1 cellspacing=0 cellpadding=3><br />
<tr><br />
<th>Tid</th><br />
<th>Tcol2</th><br />
<th>Uid</th><br />
<th>Ucol2</th><br />
</tr><br />
<tr><br />
<td>1</td><br />
<td>a</td><br />
<td>1</td><br />
<td>X</td><br />
</tr><br />
<tr><br />
<td>1<br></td><br />
<td>a<br></td><br />
<td>2<br></td><br />
<td>Y</td><br />
</tr><br />
<tr><br />
<td>1</td><br />
<td>b<br></td><br />
<td>1</td><br />
<td>X</td><br />
</tr><br />
<tr><br />
<td>1</td><br />
<td>b<br></td><br />
<td>2<br></td><br />
<td>Y</td><br />
</tr><br />
<tr><br />
<td>2</td><br />
<td>c</td><br />
<td>1</td><br />
<td>X</td><br />
</tr><br />
<tr><br />
<td>2</td><br />
<td>c</td><br />
<td>2</td><br />
<td>Y</td><br />
</tr><br />
</table><br />
</td></tr></table><br />
<br />
Requête SQL pour faire la jointure : filtrer les lignes dont la 1ère colonne de T correspond à la 1ère colonne de U :<br />
<source lang='SQL'><br />
SELECT *<br />
FROM T, U<br />
WHERE Tid = Uid<br />
</source><br />
<br />
Résultat :<br />
<table border=1 cellspacing=0 cellpadding=3><br />
<tr><br />
<th>Tid</th><br />
<th>Tcol2</th><br />
<th>Uid</th><br />
<th>Ucol2</th><br />
</tr><br />
<tr><br />
<td>1</td><br />
<td>a</td><br />
<td>1</td><br />
<td>X</td><br />
</tr><br />
<tr><br />
<td>1</td><br />
<td>b<br></td><br />
<td>1</td><br />
<td>X</td><br />
</tr><br />
<tr><br />
<td>2</td><br />
<td>c</td><br />
<td>2</td><br />
<td>Y</td><br />
</tr><br />
</table><br />
<br />
'''Jointure avec JOIN'''<br />
<br />
Le même résultat est obtenu avec JOIN en précisant les colonnes qui doivent correspondre :<br />
<source lang='SQL'><br />
SELECT *<br />
FROM T JOIN U ON (Tid=Uid)<br />
</source><br />
<br />
Résultat :<br />
<table border=1 cellspacing=0 cellpadding=3><br />
<tr><br />
<th>Tid</th><br />
<th>Tcol2</th><br />
<th>Uid</th><br />
<th>Ucol2</th><br />
</tr><br />
<tr><br />
<td>1</td><br />
<td>a</td><br />
<td>1</td><br />
<td>X</td><br />
</tr><br />
<tr><br />
<td>1</td><br />
<td>b<br></td><br />
<td>1</td><br />
<td>X</td><br />
</tr><br />
<tr><br />
<td>2</td><br />
<td>c</td><br />
<td>2</td><br />
<td>Y</td><br />
</tr><br />
</table><br />
<br />
'''Questions :'''<br />
* Afficher les mesures vous avez effectuées.<br />
<source lang='SQL'> <br />
SELECT * <br />
FROM measures m JOIN users u ON (m.User = u.User_id)<br />
WHERE u.name='BARRIOT';<br />
</source><br />
<br />
* Afficher les mesures effectuées par les personnes du même groupe de TP que vous.<br />
<source lang='SQL'><br />
SELECT * <br />
FROM measures m JOIN users u ON (m.User = u.User_id)<br />
WHERE groupe=0;<br />
</source><br />
<br />
* Afficher les mesures concernant des écotypes pour lesquels la bactérie est naturellement présente.<br />
<source lang='SQL'><br />
SELECT * <br />
FROM measures m JOIN images i ON (m.Source=i.filename) JOIN ecotype e ON (i.Accession_id = e.Accession_id)<br />
WHERE Natural_Bacterial_occurence=1;<br />
</source><br />
<br />
<br />
* De même, mais ayant le marqueur SNP1 valant A<br />
<source lang='SQL'><br />
SELECT * <br />
FROM measures m JOIN images i ON (m.Source=i.filename) JOIN ecotype e ON (i.Accession_id = e.Accession_id) JOIN genotype g ON (e.Accession_id=g.Accession_id)<br />
WHERE Natural_Bacterial_occurence=1 AND Marker_SNP1='A';<br />
</source><br />
<br />
=== Synthèse des éléments d'une requête ===<br />
<source lang='SQL'><br />
SELECT -- choix des colonnes. ex: Accession_id, Country<br />
FROM -- choix des tables. ex: ecotype<br />
WHERE -- filtre éventuel sur les lignes à afficher ex: Bacterial_Natural_occurence = 1<br />
GROUP BY -- regroupement éventuel de lignes ex: Accession_id<br />
HAVING -- filtre sur les valeurs des lignes regroupées ex: COUNT(*)>1<br />
ORDER BY -- tri des résultats ex: Country DESC<br />
</source><br />
<br />
== Ajout de données ==<br />
<br />
Exemple de requête :<br />
<source lang='SQL'><br />
INSERT INTO ecotype ('Accession_id', 'Country') <br />
VALUES ('patient_0', 'France');<br />
</source><br />
<br />
== Mise à jour ==<br />
<br />
Exemple de requête :<br />
<source lang='SQL'><br />
UPDATE ecotype <br />
SET Bacterial_Natural_occurence=1<br />
WHERE Accession_id='patient_0';<br />
</source></div>Barriot