SQLite Forum

3.31.1: create table with multiple primary key columns
Login
Keith,

The 'parent' is the Sites table. If a user tries to enter any data and the site_id field does not exist in the Sites table an error message box would be displayed.

No entered data can be deleted via the application. All data are needed for a regulatory compliance audit.

Because the value in the wxsite_id column in the WeatherData table must exist before data are committed how should I define that table?

Current definition:

create table WeatherData (
    wxsite_id INT not null
              references WeatherSites(wxsite_id)
              on delete cascade on update cascade,
    sampdate TEXT not null,
    samptime TEXT not null,
    sampby TEXT,
    wxparam_name TEXT references WeaatherParams(wxparam_name)
       on delete cascade on update cascade,
    wxquant REAL not null,
    notes TEXT,
    constraint primary key (wxsite_id, sampdate, samptime, wxparam_name)
    )without rowid;