Forum Discussion

Richard Dunne's avatar
Richard Dunne
Copper Contributor
Apr 16, 2025

Insert & Update both implemented wrong semantically

Insert means to introduce something, adding/entering something new

Update means to change something, change and existing value.

Semantically and logically speaking, Insert should only be used to enter data into an empty or partially empty record/table.  Update should only be used to change existing values within a record/table.  

Using a 5 column table as an example where column 1 is an email address

Example1 INSERT INTO table (Column1,Column2,Column3) VALUES (value1,value2,value3)

Or

Example2 INSERT INTO table VALUES (value1,value2,value3,value4,value5)

With example 1, 2 columns are left empty

Semantically, insert should be used to populate columns for the first time

INSERT INTO table (column4, column5) VALUES (value4,value5) where column1 = "EmailAddress"

Then for example,

UPDATE table SET COLUMN2 = "newValue" WHERE COLUMN1 = "EmailAddress"

Updating (setting) an empty column should cause an error, cannot update an empty column

SQL, a great idea, pity its implementation is tainted by bad design.  SQL works, but its design/implementation of Insert & Update is semantically wrong. IMO

As the saying goes, if it isn't broken, don't fix it.  Who cares about semantics or logic.

1 Reply

  • SivertSolem's avatar
    SivertSolem
    Iron Contributor

    You should remember that T-SQL doesn't work with colums. It works with rows.

    Thus, Update is syntactically correct, as it modifies existing rows.

    Likewise, Insert creates new rows.

Resources