Structuri Ierarhice

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Structuri Ierarhice - Presentation Transcript

    1. Structuri ierarhice Stocarea şi utilizarea arborilor în baze de date
    2. Structuri ierarhice Electronice Monitoare Aparate foto CRT LCD Compacte SLR Digitale Pe film
    3. Reprezentare recursivă
      • +-------------+----------------------+--------+
      • | category_id | name | parent |
      • +-------------+----------------------+--------+
      • | 1 | Electronice | NULL |
      • | 2 | Monitoare | 1 |
      • | 3 | CRT | 2 |
      • | 4 | LCD | 2 |
      • | 5 | Aparate foto | 1 |
      • | 6 | SLR | 5 |
      • | 7 | Digitale | 6 |
      • | 8 | Pe film | 6 |
      • | 9 | Compacte | 5 |
      • +-------------+----------------------+--------+
    4. Reprezentare plană
      • +-------------+----------------------+--------+------+-------+
      • | category_id | name | parent | rank | depth |
      • +-------------+----------------------+--------+------+-------+
      • | 1 | Electronice | NULL | 1 | 0 |
      • | 2 | Monitoare | 1 | 2 | 1 |
      • | 3 | CRT | 2 | 3 | 2 |
      • | 4 | LCD | 2 | 4 | 2 |
      • | 5 | Aparate foto | 1 | 5 | 1 |
      • | 6 | SLR | 5 | 6 | 2 |
      • | 7 | Digitale | 6 | 7 | 3 |
      • | 8 | Pe film | 6 | 8 | 3 |
      • | 9 | Compacte | 5 | 9 | 2 |
      • +-------------+----------------------+--------+------+-------+
    5. Reprezentare lineară
      • +-------------+----------------------+-------- - ------ - -------+
      • | category_id | name | tree_path |
      • +-------------+----------------------+-------- - ------ - -------+
      • | 1 | Electronice | 001 |
      • | 2 | Monitoare | 001.001 |
      • | 3 | CRT | 001.001.001 |
      • | 4 | LCD | 001.001.002 |
      • | 5 | Aparate foto | 001.00 2 |
      • | 6 | SLR | 001.002.001 |
      • | 7 | Digitale | 001.002.001.001 |
      • | 8 | Pe film | 001.002. 001. 002 |
      • | 9 | Compacte | 001.002.00 2 |
      • +-------------+----------------------+-------- - ------ - -------+
    6. Reprezentare preordonată Electronice Monitoare Aparate foto CRT LCD Compacte SLR Digitale Pe film 1 2 3 4 5 6 7 18 8 9 10 11 15 16 12 13 14 17
    7. Reprezentare preordonată
      • +-------------+----------------------+-----+-----+
      • | category_id | name | lft | rgt |
      • +-------------+----------------------+-----+-----+
      • | 1 | Electronice | 1 | 18 |
      • | 2 | Monitoare | 2 | 7 |
      • | 3 | CRT | 3 | 4 |
      • | 4 | LCD | 5 | 6 |
      • | 5 | Aparate foto | 8 | 17 |
      • | 6 | SLR | 9 | 14 |
      • | 7 | Digitale | 10 | 11 |
      • | 8 | Pe film | 12 | 13 |
      • | 9 | Compacte | 15 | 16 |
      • +-------------+----------------------+-----+-----+
    8. Parcurgere MPTT Electronice Monitoare CRT LCD Aparate foto SLR Compacte Digitale Pe film 1 2 3 4 5 6 7 8 9 10 11 12 1314 15 1617 18
    9. Parcurgere MPTT
      • SELECT * FROM tree WHERE lft >= 2 AND rgt <= 7 ORDER BY lft
      • SELECT * FROM tree WHERE lft <= 10 AND rgt >= 11
      • SELECT * FROM tree WHERE rgt = lft+1 AND lft > 8 AND rgt < 17
      Electronice Monitoare CRT LCD Aparate foto SLR Compacte Digitale Pe film 1 2 3 4 5 6 7 8 9 10 11 12 1314 15 1617 18
    10. Inserare MPTT Electronice Monitoare CRT LCD Aparate foto SLR Compacte Digitale Pe film 1 2 3 4 5 6 7 8 9 10 11 12 1314 15 1617 18 Plasm ă
    11. Inserare MPTT
      • UPDATE tree SET rgt = rgt + 2 WHERE rgt > 6
      • UPDATE tree SET lft = lft + 2 WHERE lft > 6
      • INSERT INTO tree SET lft = 7, rgt = 8, name = “Plasm ă ”
      Electronice Monitoare CRT LCD Aparate foto SLR Compacte Digitale Pe film 1 2 3 4 5 6 7 8 9 101112 1 3 1 4 1 5 1 6 1 7 1 8 1 9 20 Plasm ă
    12. Ştergere MPTT Electronice Monitoare CRT LCD Aparate foto SLR Compacte Digitale Pe film 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
    13. Ştergere MPTT
      • DELETE FROM tree WHERE lft >= 9 AND rgt <= 14
      • UPDATE tree SET rgt = rgt - 6 WHERE rgt > 14
      • UPDATE tree SET lft = lft - 6 WHERE lft > 14
      Electronice Monitoare CRT LCD Aparate foto SLR Compacte Digitale Pe film 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2
    14. Resurse adiţionale
      • Managing Hierarchical Data in MySQL
        • http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
      • Storing Hierarchical Data in a Database
        • http://www.sitepoint.com/article/hierarchical-data-database
      • Four ways to work with hierarchical data
        • http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/4047

    + alex.albualex.albu, 5 months ago

    custom

    343 views, 0 favs, 1 embeds more stats

    Catalin a prezentat la Geek Meet #5 Timisoara un ex more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 343
      • 255 on SlideShare
      • 88 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds
    • 88 views on http://geekmeet.ro

    more

    All embeds
    • 88 views on http://geekmeet.ro

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories