Pular para o conteúdo principal

Postagens

Mostrando postagens de fevereiro, 2024

SQL: Naming external identification code fields at database.

Demand Use "id_{context}" to name fields of external identification codes and "{context}_id" to internal ones. Description When creating a column in a table that reference an id (identification code) of a table located at the database you are dealing it should be named as "{Table Name}_id". When creating a column in a table that reference an id of a context external to the database you are dealing with  it should be named as "id_{Context Name}". Examples 1: CREATE TABLE customer ( 2:     id INT NOT NULL, 3:   name VARCHAR(100) NOT NULL, 4:     id_ssn COMMENT ' the United States, the Social Security number', 5:    user_id INT NULL COMMENT 'if the customer have a system login it will be refernced here', 6:      PRIMARY KEY (id), 7:     UNIQUE `uq_ssn` (`ssn`), 8:      CONSTRAINT `fk_customers_user_id_users_user_id` 9:           FOREIGN KEY (`user...