This is a question about naming conventions in SQL.
How should you name your table and your fields when they are both described by the same word or phrase. Is it ok to have the same name for both of them.
My example:
I am creating a question and each question can have one to many answers so I figured that the best way to do this is to have a structure like this:
CREATE TABLE question
(
id INT NOT NULL IDENTITY(1,1),
question VARCHAR(250) NOT NULL
)
CREATE TABLE answer
(
id INT NOT NULL IDENTITY(1,1),
question_id INT NOT NULL,
answer VARCHAR(50) NOT NULL
)
(The two tables are not that small but I removed some columns for simplicity)
The problem is that I do not think that having a field with the same name as the table does not follow proper naming conventions.
I thought of changing the question and answer column to something like text but unfortunately that is a reserved word and that is against the standard naming conventions, in addition to that I would have to use []
tags when referring to them.
Any recommendations on how to name the columns or the tables?