<?xml version="1.0" encoding="UTF-8"?>
<!--
    Document   : ciudades.xml
    Author     : Frank Aguirre
    Description:
        Estructura de la tabla ciudades.
-->
<table>
    <column>
        <name>alias</name>
        <type>text</type>
    </column>
    <column>
        <name>ciudad</name>
        <type>character varying(100)</type>
        <null>NO</null>
    </column>
    <column>
        <name>creation_date</name>
        <type>timestamp</type>
    </column>
    <column>
        <name>codeid</name>
        <type>character varying(5)</type>
    </column>
    <column>
        <name>idciudad</name>
        <type>serial</type>
        <null>NO</null>
    </column>
    <column>
        <name>idprovincia</name>
        <type>integer</type>
        <null>NO</null>
    </column>
    <column>
        <name>last_nick</name>
        <type>character varying(50)</type>
    </column>
    <column>
        <name>last_update</name>
        <type>timestamp</type>
    </column>
    <column>
        <name>latitude</name>
        <type>double precision</type>
    </column>
    <column>
        <name>longitude</name>
        <type>double precision</type>
    </column>
    <column>
        <name>nick</name>
        <type>character varying(50)</type>
    </column>
    <constraint>
        <name>ciudades_pkey</name>
        <type>PRIMARY KEY (idciudad)</type>
    </constraint>
    <constraint>
        <name>ca_ciudades_provincias</name>
        <type>FOREIGN KEY (idprovincia) REFERENCES provincias (idprovincia) ON DELETE CASCADE ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>uniq_ciudad_idprovincia</name>
        <type>UNIQUE (ciudad, idprovincia)</type>
    </constraint>
    <constraint>
        <name>ca_ciudades_users_last_nick</name>
        <type>FOREIGN KEY (last_nick) REFERENCES users (nick) ON DELETE SET NULL ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_ciudades_users_nick</name>
        <type>FOREIGN KEY (nick) REFERENCES users (nick) ON DELETE SET NULL ON UPDATE CASCADE</type>
    </constraint>
</table>