Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
Zum Entwickeln und Nachvollziehen habe ich immer an diesem Bild von Hand und im Kopf rumgeschoben. Vielleicht hilft Dir das ja auch.Mik3e hat gesagt.:Für das Bearbeiten der Struktur (ist der nächste Schritt) werde ich dich sicher noch ein paar mal quälen müssenWerde mir mal deinen Pseudo-Code mit den Berechnungen zu Gemüte führen.
--------------------------------------
Auto | | |
--------------------------------------
| Opel | |
--------------------------------------
| Audi | |
--------------------------------------
Motorrad | | |
--------------------------------------
| Yamaha | |
--------------------------------------
| | YZF R1 |
--------------------------------------
| | Tomcat |
--------------------------------------
$categoryArray[n]["id"]=ID des Knotens (PK der DB)
$categoryArray[n]["name"]=Name des Knotens
$categoryArray[n]["layer"]=Ebene des Knotens
// PSEUDOCODE
getMaxValue($categoryArray[*]["layer"].
1. Neue Kategorie (Child-Node) UNTER |<Liste aller Knoten>| anlegen
2. Position in Ebene:
- Am Anfang
- Am Ende
- Nach |<Knoten>|
5. The nested set model has an implied ordering of siblings which the
adjacency list model does not.
To insert a new node, G1, under part G.
We can insert one node at a time like this:
BEGIN ATOMIC
DECLARE right_most_sibling INTEGER;
SET right_most_sibling
= (SELECT rgt
FROM Frammis
WHERE part = 'G');
UPDATE Frammis
SET lft = CASE WHEN lft > right_most_sibling
THEN lft + 2
ELSE lft END,
rgt = CASE WHEN rgt >= right_most_sibling
THEN rgt + 2
ELSE rgt END
WHERE rgt >= right_most_sibling;
INSERT INTO Frammis (part, qty, wgt, lft, rgt)
VALUES ('G1', 3, 4, parent, (parent + 1));
COMMIT WORK;
END;
Ja, parent ist in dem Beispiel gleich right_most_sibling.Mik3e hat gesagt.:Was mir nicht klar ist:
Die Zeile:
VALUES ('G1', 3, 4, parent, (parent + 1));
Welchen Wert hat parent Ist das Right von Parent?
The second way to add, and delete nodes is to update the left and right values of all nodes to the right of the new node. Let’s have a look at an example. We want to add a new type of fruit, a ‘Strawberry’, as the last node and a child of ‘Red’. First, we’ll have to make some space. The right value of ‘Red’ should be changed from 6 to 8, the 7-10 ‘Yellow’ node should be changed to 9-12 etc. Updating the ‘Red’ node means that we’ll have to add 2 to all left and right values greater than 5.
We’ll use the query:
UPDATE tree SET rgt=rgt+2 WHERE rgt>5;
UPDATE tree SET lft=lft+2 WHERE lft>5;
Now we can add a new node ‘Strawberry’ to fill the new space. This node has left 6 and right 7.
INSERT INTO tree SET lft=6, rgt=7, title='Strawberry';