Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008
    Location
    Australia
    Posts
    23

    Distinct representation of a type

    How would you implement two distinct representations of a single type in SQL? eg

    point cartesian (Xcoord, Ycoord)
    point polar (radius, angle)

    What would the SQL code be to define this type?

  2. #2
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    The nearest thing that Standard SQL has is CREATE DOMAIN, which is really just an alias for an existing type and some constraints. Several DBMSs allow user-defined types but they use proprietary syntax for it.

  3. #3
    Join Date
    Aug 2008
    Location
    Australia
    Posts
    23
    Thanks, reading the Date text (An Intro to Database Systems, p 116) I see he uses Tutorial D syntax as follows to do this;
    TYPE POINT
    POSSREP CARTESIAN {X RATIONAL, Y RATIONAL}
    POSSREP POLAR {R RATIONAL, O RATIONAL};

    I will look into CREATE DOMAIN (I am using postgreSQL). Does CREATE DOMAIN achieve what Date does using POSSREP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •