---
type: archive
area: archive
status: archived
date: 2026-05-03
created: 2026-05-03
updated: 1980-01-01
tags:
  - archive
---
```CYPHER
//Qst 1
Match (r:Room)<-[:TAKESPLACEIN]-(c:Course{courseNr:"1"}) return r.roomName,c.courseName;

//Qst 2
MATCH (s:Student {studentID: "2"})-[w:WORKSON]->(p:Project)
RETURN s.lastName, s.firstName, p.projectName, w.hours;

//Qst 3
Match(s:Student)-[w:WORKSON]->(:Project)
With s.firstName as FirstName, Count(w) as NbrProject
where NbrProject > 2
return FirstName, NbrProject
ORDER By NbrProject DESC;
//Qst4
MATCH (s:Student {studentID: "4"}), (c:Course {courseNr: "3"})
CREATE (s)-[:ENROLLEDIN]->(c)
RETURN s, c;
```

```JSON
db.exam2023.insert( {"num":10, "nom":"Hamza Chaqchaq", "age":23 , "modules":[ {"intitule":"NoSQL", "nbrHeures":30, infos: {"NoteControleContinue":18, "NoteExamen":16, "NoteTP":15} } ]} )
db.exam2023.insert( {"num":10, "nom":"Hiba Tazi", "age":22 , "modules":[ {"intitule":"NoSQL", "nbrHeures":30, infos: {"NoteControleContinue":16, "NoteExamen":14, "NoteTP":16} } ]} )

```

```JSON
db.exam2023.aggregate([
  {
    $project: {
      num: 1,
      nom: 1,
      age: 1,
      nosqlModules: {
        $filter: {
          input: "$modules",
          as: "module",
          cond: { $eq: ["$$module.intitule", "NoSQL"] }
        }
      }
    }
  },
  {
    $project: {
      num: 1,
      nom: 1,
      age: 1,
      nosqlFinalScore: {
        $sum: [
          { $multiply: [{ $arrayElemAt: ["$nosqlModules.infos.NoteControleContinue", 0]}, 0.3] },
          { $multiply: [{ $arrayElemAt: ["$nosqlModules.infos.NoteTP", 0]}, 0.2] },
          { $multiply: [{ $arrayElemAt: ["$nosqlModules.infos.NoteExamen", 0]}, 0.5] }
        ]
      }
    }
  }
]);

```

### Ex4

``` CQL
CREATE KEYSPACE EtudiantDB WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'datacenter1': 3, 'datacenter2': 3, 'datacenter3': 3 };
```

``` CQL
CREATE TABLE annuaires.numservice_annuaire (
    numservice int PRIMARY KEY,
    adresse frozen<annuaires.adresse>,
    position frozen<annuaires.localisation>
);

INSERT INTO annuaires.numservice_annuaire (numservice, adresse, position) VALUES 
    (5, {ip: '10.5.2.250', dns: 'biblio.fstf.co.ma'}, {compus: 'bibliothèque', batiment: 'B', salle: 12}),
    (1, {ip: '10.5.2.120', dns: 'bg.fstf.co.ma'}, {compus: 'informatique', batiment: 'B', salle: 9}),
    (0, {ip: '10.5.1.204', dns: 'info.fsff.co.ma'}, {compus: 'central', batiment: 'A', salle: 1}),
    (2, {ip: '10.5.1.249', dns: 'math.fstf.co.ma'}, {compus: 'mathématique', batiment: 'B', salle: 4}),
    (4, {ip: '10.5.2.251', dns: 'Sco.fstf.co.ma'}, {compus: 'scolarité', batiment: 'B', salle: 4}),
    (3, {ip: '10.5.2.252', dns: 'phy.fstf.co.ma'}, {compus: 'physique', batiment: 'B', salle: 4});
```

```CYPHER
CREATE (e:Student {id: 1, nom: 'Chaqchaq', age: 23}) 
CREATE (s:Student {id: 2, nom: 'Tazi', age: 22}) 
CREATE (m:Module {intitule: 'Math', hours: 30})
CREATE (s)-[:LEARNS {noteCC: 18, noteEx: 15, noteTp: 16}]->(m)
CREATE (e)-[:LEARNS {noteCC: 15, noteEx: 0, noteTp: 17}]->(m);
```

```CYPHER
Match (s:Student)-[:LEARNS]->(m:Module) where m.intitule = 'Nosql' return s.nom;
```

```CYPHER
MATCH (m:Module)<-[r:LEARNS]-(s:Student)
WHERE r.noteEx >= 14
RETURN DISTINCT m.intitule,Collect(r.noteEx);
```

```CYPHER
MATCH (m:Module)<-[r:LEARNS]-(s:Student)
WITH r.noteCC * 0.3 + r.noteTp * 0.2 + r.noteEx * 0.5 as note, s.nom as nomStudent
Where note > 10
RETURN nomStudent,COLLECT(note);
```