Introduction to Moving Objects Databases

Document Sample
Introduction to Moving Objects Databases Powered By Docstoc
					     Introduction to
Moving Objects Databases
Questions about Moving Objects
Points         Questions                         Regions            Questions
People         When did Bush meet Arafat?
                                                 Forests, rivers,   How fast is the Amazon rain
Animals        Determine trajectories of         rivers             forest shrinking?
               birds, whales, …                                     What is the minimal extent of
               Which distance do they                               river X during the year?
               traverse, at which speed?
                                                 Glaciers           Does the polar ice cap grow?
Sattelites,    Which sattelites will get close                      Does it move?
spacecraft,    to the route of this spacecraft
                                                 Storms             Where is tornado heading?
planets        within the next 4 hours?
                                                                    When will it reach Florida?
Cars: taxi-    Which taxi is closest to a
cabs, trucks   passenger request position?       People, troops,    Movements of the celts in the
                                                 armies             2nd centure B.C.
               Which routes are used
               regularly by trucks?                                 Hannibal traversing the Alps.
                                                                    Show his trajectory.
Air planes     Were any two planes close to
               a collision?                      Traffic jams       How has been the size of the
                                                                    traffic jams changing during the
               Did planes cross the air
                                                                    last hour?
               territory of state X?
                                                 Oil spills         Which parts of the coast will be
Ships          Are any ships heading
                                                                    touched tomorrow?
               towards shallow areas?
                                                 Cancer             Can we find in a series of X-ray
Military       All kinds of military analyses
                                                                    images a growing cancer?
vehicles
                                                                    How fast does it grow? How big
                                                                    was it on June 1, 1995?
Moving Objects Databases

   Moving objects database is a database
    that can represent and query moving
    objects
   Moving object is a geometry that
    changes over time continuosly
   How to extend database technology to
    support moving object databases?
Outline of this lecture

 Database Management Systems
 Spatial Databases

 Temporal Databases
 Moving Objects in Databases
Database Management Systems
   Database management system (DBMS) is a piece of
    software that manages a database
   Database is a repository of interrelated data items that are
    central to the business of an enterprise/institution
   Physical level:
       Data organization on storage media (files)
   Logical level:
       Data model and query/data manipulation language
       E.g., relational data model and SQL
   External views:
       Application-specific view of data from logical level
Database Management Systems
   Classical database management systems were
    conceived for relatively simple business
    applications:
       E.g., in the relational data model, simple data types
        (integers, floating-point numbers, short text strings)
   We would like to widen the scope:
       Data: Images, geographic maps, music, videos, data
        from scientific experiments, meteorological
        measurements
       Queries:
            “Retrieve images containing shapes similar to a given one”
            “Produce a map of rainfall over some terrain”
   In order to formulate queries in a simple manner
    and to process queries efficiently, we need to
    extend data model and query language
Limitations of Classical Databases
   No way to represent geometric shapes:
       Representation of a region as a collection of
        coordinates in numeric attributes is difficult to
        handle
   No way to represent development of entities
    over time:
       Past state of the world is not kept
   No way to represent objects moving right
    now:
       Continuous updates are not feasible
Outline of this lecture

 Database Management Systems
 Spatial Databases

 Temporal Databases
 Moving Objects in Databases
Spatial Databases
   Spatial database (DBMS) allows representing and
    querying geometries in a natural way
   Entities to be stored in a spatial database:
       Cities, rivers, road networks, landmarks, boundaries of
        countries, hospitals, subway stations, forests, corn fields
   Fundamental abstractions:
       Single objects: point, line, region
       Spatially related collections of objects: partition, network
Extending Data Model and
Query Language: ADTs (ROSE Algebra)
   Spatial data type (SDT) is a structure (e.g., region)
   Algebra is a collection of abstract data types, e.g., STDs, with related
    operations
   Algebra must be closed under its operations!
   The ROSE algebra:
        STDs: points, region, line
        Other data types: real, bool, …
        Operations:
             Contour: region                line
             Length: line                   real
             Inside: points x region        bool
             Adjacent: region x region      bool
             Intersection: line x line      points
             Minus: region x region         region
Extending Data Model and
Query Language: ATDs (ROSE Algebra)
   We embed SDTs into a DBMS data model (e.g., into a relational model)
    in the role of attribute types
   Sample relations:
       Cities (name: string, population: int, location: points)
       Rivers (name: string, route: line)
       Highways (name: string, route: line)
       States (name: string, area: region)
   Sample queries:
       “What is the total population of cities in France?”
            SELECT SUM(c.population)
             FROM cities AS c, states AS s
             WHERE c.location inside s.area AND s.name = ‘FRANCE’
       “Return the part of the river Rhine that is within Germany”
            SELECT intersection (r.route, s.area)
             FROM rivers AS r, states AS s
             WHERE r.name = ‘RHINE’ AND s.name = ‘GERMANY’
Extending Data Model and
Query Language: ATDs (ROSE Algebra)
   Implementation strategy:
       Data structures for SDTs
       Algorithms for SDTs operations
       Spatial index structures
       Extension of the optimizer:
            Cost functions for all methods
            Statistics about the distributions of objects in space,
              needed for selectivity estimation
            Translation rules
       User interface extensions to handle presentation of spatial data and
        input of spatial values for querying
   Some of these have become available in commercial
    systems:
       Good extensibility by attribute data types and operations:
            Oracle, IBM DB2, Informix, MySQL
Outline of this lecture

 Database Management Systems
 Spatial Databases

 Temporal Databases
 Moving Objects in Databases
Temporal Databases
   Standard DBMS describe the current state of the world

                         Name     Department
                         Lisa     Toys




   A change in the world leads to update in the database
       Previous state is lost!


                         Name     Department
                         Lisa     Books
Temporal Databases
   Application can manage time itself:
       Explicit attribute of type date or time
       Sample relation:




   Disadvantages of this approach:
       Complex query formulation
       Inefficient query processing
Temporal Databases
   Temporal projection:
       What is Bob‟s current salary?

         select Salary
         from Employee
         where Name = „Bob‟ and
                 Start <= CURRENT_DATE and
                 Stop >= CURRENT_DATE
Temporal Databases
   Sample relation:




   Compute the salary history:
       What is Bob‟s salary history?




       Need to coalesce consecutive, value-equivalent tuples
Temporal Databases
   Salary history in standard SQL
Temporal Databases



   Computing salary history is easy now:
    select Name, Salary, Start, Stop
        from Employee1
        where Name = „Bob‟
Temporal Databases



   How to compute the history of salary and title (original
    relation)?
   Need temporal join
Temporal Databases



   Need to analyze how each tuple of Employee1
    overlaps each tuple of Employee2
Temporal Databases
   Temporal join in standard SQL:
The Time Domain
   Time is a one-dimensional space extending
    from the past to the future
   Different models of time:
       Bounded vs. infinite
       Discrete vs. continuous
   Discrete and continuous time:
       With discrete time, atomic time intervals
        (chronons) are isomorfic to natural numbers
       With continuous time, points in time are
        isomorfic to real numbers
Time Dimension
   Two kinds of time:
       Valid time is the time in the real world when an event
        occurs or a fact is valid
       Transaction time is the time when a change is recorded in
        the database or a time interval during which a particular
        state of the database exists
   Temporal database (DBMS) is a database (DBMS)
    that supports valid time and/or transaction time
Extending Data Models
   General approach:
       Database facts are associated with timestamps
   Alternatives:
       Data model extended:
            Relational vs. object-oriented
       Granularity of facts:
            Tuples/objects vs. attributes
       Kind of timestamp:
            a single chronon (instant)
            a single time period (period)
            a temporal element (periods)
       Time dimension:
            Valid time
            Transaction time
            Both dimensions
Extending Model: Valid-Time Relations
1. On January 1, Lisa started             Name   Department   Time
to work in the toys department and is
expected to work there until January 15   Lisa   Toys         [1;15]

                                          Name Department      Time
2. On January 8, Lisa moved to
                                          Lisa   Toys          [1;7]
the books department and is
expected to work there until January 15   Lisa   Books         [8;15]


3. On January 14, Lisa moved back         Name   Department    Time
to the toys department and is
expected to work there until January 20   Lisa   Toys          [1;7]
                                          Lisa   Books         [8;13]
                                          Lisa   Toys          [14;20]
Extending Model:
Transaction-Time Relations
                                          Name   Department   Time
1. On January 6, it was recorded
that Lisa worked in the toys department   Lisa   Toys         [6; uc]

                                          Name   Department   Time
2. On January 10, it was recorded that Lisa      Toys         [6;9]
Lisa had moved to the books department
                                       Lisa      Books        [10;uc]



                                          Name   Department   Time
2. On January 12, it was recorded that
Lisa had moved back                       Lisa   Toys         [6;9]
to the toys department
                                          Lisa   Books        [10;11]
                                          Lisa   Toys         [12;uc]
  Extending Data Model:
  Bitemporal Relations
1. On January 6, it was recorded that Lisa
                                              Name Department     Time
   had started working in the toys
   department on January 1 and was            Lisa   Toys         [6; uc] x [1;15]
   expected to work there until January 15
                                              Name   Department   Time
2. On January 10, it was recorded that Lisa
                                              Lisa   Toys         [6;9] x [1;15]
   had moved to the books department on
   January 8. She was still expected to       Lisa   Toys         [10;uc] x [1;7]
   work until January 15.
                                              Lisa   Books        [10;uc] x [8;15]

                                              Name   Department Time
                                              Lisa   Toys         [6;9] x [1;15]
2. On January 12, it was recorded that Lisa
   would move back to the toys                Lisa   Toys         [10;uc] x [1;7]
   department on January 14 and               Lisa   Books        [10;11] x [8;15]
    would stay there until January 20
                                              Lisa   Books        [12;uc] x [8;13]
                                              Lisa   Toys         [12;uc] x [14;20]
Extending Data Model: BCDM model
   Data model extended: relational
   Granularity of facts: tuple
   Model of time: bounded, discrete
   Kind of timestamp: a single chronon
   Time dimension: both dimensions


    Name   Department   Time


    Lisa   Toys         {(6,1), …, (6, 15), …, (9,1), …, (9, 15),
                         (10, 1), …, (10,7), …, (uc, 1), …, (uc, 7),
                         (12, 14), …, (12, 20), …, (uc, 14), … (uc, 20)}
    Lisa   Books        {(10, 8), … , (10, 15), …, (11, 8), … , (11, 15),
                         (12, 8) , … (12, 15), …, (uc, 8), … , (uc, 13)}
Extending Query Language: TSQL2
   TSQL2:
       is a superset of SQL92
       is based on BCDM model
       supported by TimeDB (ETH Zurich)
   Sample data definition command:
        CREATE TABLE prescription (
        name char(30),
        drug char(30),
        dosage char(30) )
        AS VALID DAY AND TRANSACTION
   Kinds of relations:
       Snapshot
       Valid-time
       Transaction-time
       Bitemporal
Extending Query Language: TSQL2
   Sample queries:
        “What has ever been prescribed any drugs?”
          SELECT SNAPSHOT name
          FROM prescription
        “What drugs were prescribed to Lisa?”
          SELECT drug
          FROM prescription
          WHERE name = ‘Lisa’
        “What drugs have been prescribed together with aspirin?”
         SELECT p1.name, p2.drug
         FROM prescription AS p1, prescription AS p2
          WHERE p1.drug = ‘aspirin’ AND p2.drug<>’aspirin’
           AND p1.name = p2.name
        “Which drugs were Lisa prescribed during 1999?”
          SELECT p.drug
         FROM prescription AS p
         WHERE p.name = ‘Lisa’ AND VALID(p) OVERLAPS PERIOD ‘[1999]’ DAY
        “What did the physician believe on September 10, 1998, was Lisa‟s prescription
         history?”
          SELECT drug
          FROM prescription AS p
          WHERE name = ‘Lisa’ AND TRANSACTION(p) OVERLAPS DATE ‘1998-09-10’
Outline of this lecture

 Database Management Systems
 Spatial Databases

 Temporal Databases
 Moving Objects in Databases
Moving Objects in Databases
   Moving object is a geometry that
    changes over time continuosly
   Moving objects database is a database
    that can represent and query moving
    objects
   Two perspectives on
     moving objects databases:
     Location management perspective
     Spatio-temporal data perspective
Location Management Perspective
   Location management database is a snapshot database that is used to:
        maintain dynamically the locations of a set of currently moving objects
        ask queries about the current or near-future positions of
         the moving objects (monitoring)
   Main task:
        Keeping the positions of a set of objects in a database,
         e.g., a set of taxi cars, up-to-date
   Scenario:
        Moving objects send their current positions to the database and
         the database performs updates
   Trade-off:
        If updates performed very often, then
             the error is small
             the update load is very high
        If updates performed less frequently, then
             the update load is low
             the error is large
   Solution:
        Additionaly, store speed and direction of moving objects
        Use this information to predict near-future objects‟ positions
Spatio-Temporal Data Perspective
   Spatio-temporal database is a spatial database that keeps history of
    changes to spatial objects
   Two basic questions:
        What kinds of data are stored in spatio-temporal databases?
             Point, line, region, network, partition
        Which kinds of change may occur?
             Discrete change: any kind of data
             Continuous change: point and region
   Moving object is a geometry that experience continuous changes
   Two most important abstractions of moving objects:
        Moving point is an abstraction of a physical object moving around in the
         plane, for which only position is relevant
        Moving region is an abstraction of an entity in the plane that changes its
         position, extent, and shape
Extending Data Model and Query
Language:
Temporal Database with SDTs
   Idea:
         Use a temporal DBMS and extend it with spatial data types (SDTs).
   Example: TSQL2/BCDM extended with the ROSE algebra
   Sample data definition command:
         CREATE TABLE real_estate (
           owner char(30),
            area region)
         AS VALID DAY
    Sample query:
    “Show the properties adjacent to the property of Charles Smith as of March 17,
     1977”
         SELECT r2.area
         FROM real_estate AS r1, real_estate AS r2
         WHERE r1.owner = ‘Charles Smith’ AND
         VALID(r1) OVERLAPS DATE ‘[1977-03-17]’ AND
         r1.area ADJACENT r2.area
   This approach supports discrete changes, but does not support moving objects,
    i.e., continuous changes!
Extending Data Model and Query Language:
Spatio-Temporal Data Types
   Idea:
       Use spatio-temporal data types with suitable operations as attribute types in
        a snapshot DBMS
   Spatio-temporal data types: mpoint, mregion
   Operations:
      Intersection: mpoint x mregion          mpoint
      Distance:      mpoint x mpoint          mreal
      Min:          mreal                     real
      Trajectory:    mpoint                   line
      Deftime:       mpoint                   periods
      At_time:       mregion x instant        region
      At_time:       mbool x instant          bool
      Length:       line                      real
      Adjacent:     mregion x mregion         mbool

   This approach can manage both discrete and continuous
    changes!
Extending Data Model and Query Language:
Spatio-Temporal Data Types
   Sample relations:
        real_estate (owner: char(30), area:mregion)
        flight (id: string, from: string, to: string, route:
         mpoint)
        weather(id: string, kind: string, area: mregion)
   Sample queries:
        “Show the properties adjacent to the property of Charles Smith as of March
         17, 1977”
          SELECT at_time(r2.area, instant(‘March 17, 1977’))
          FROM real_estate AS r1, real_estate AS r2
          WHERE r1.owner = ‘Charles Smith’ AND
                defined(adjacent(r1.area, r2.area),
                        instant(‘March 17, 1977’)) = ‘true’
        ”Retrieve any pairs of airplanes, which, during their flight, came closer to
         each other than 500 meters”
          SELECT f.id, g.id
           FROM flight AS f, flight AS g
           WHERE f.id <> g.id AND min(distance(f.route,g.route)) < 0.5
        At what time was flight BA488 within the snowstorm with ID S16?”
         SELECT deftime(intersection(f.route, w.area))
         FROM flight AS f, weather AS w
         WHERE f.id = ’BA488’ AND w.id = ’S16’
Summary
   Moving object databases are databases that allow
    efficiently representing and querying moving
    objects
   Moving object is a geometry that changes
    continuously
   Classical data models and query languages (and
    their implementations) need to be extended to
    support moving objects:
       Spatial extension:
            Spatial databases: SDTs with operations (ROSE algebra)
       Temporal extension:
            Temporal databases: BCDM data model and TSQL2
       Spatio-temporal extensions:
            Temporal databases with SDTs
            Spatio-temporal data types with related operations
       Location management database