Data Structures

Version 9.1 by Kerem Yollu on 2025/03/22 14:48

Data Structures for KPM and database relations

Models

Address

  • DROP TABLE IF EXISTS public.address;

    CREATE TABLE public.address
    (
        uid SERIAL PRIMARY KEY,
        country CHAR(2) NOT NULL,              -- ISO 3166-1 alpha-2 (e.g., 'CH')
       region VARCHAR(100),                   -- State or canton
       city VARCHAR(100) NOT NULL,
        postcode VARCHAR(20) NOT NULL,
        street VARCHAR(255) NOT NULL,
       number VARCHAR(20),   
        unit VARCHAR(50),                      -- Apartment/Suite/Floor/etc.
       extra_address VARCHAR(255),            -- Additional info
       lon DOUBLE PRECISION,                  -- Longitude (optional)
       lat DOUBLE PRECISION                   -- Latitude (optional)
    )

    TABLESPACE pg_default;

    ALTER TABLE IF EXISTS public.address
       OWNER to kpm_rw;

    COMMENT ON TABLE public.address
       IS 'addresses table, instead of making use of addresses for ever company, customer and co... Prefer to make addresses table and then assign it to a company or a user etc.';

Common table having the same Cols. an pointing to no other table