How should columns in a database table that have a PK/FK relationship be named? Should their names contain a reference to the table they are in? Consider the examples below. Each employee has an ID which is a FK in the salaries table.
/* Employees Option 1*/
CREATE TABLE dbo.Employees
(
EmployeeID INT PRIMARY KEY,
EmployeeFirstName VARCHAR(32),
EmployeeLastName VARCHAR(32),
EmployeeEmail VARCHAR(255) -- , ...
)
/* Employees Option 2*/
CREATE TABLE dbo.Employees
(
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(32),
LastName VARCHAR(32),
Email VARCHAR(255) -- , ...
)
/* Employees Option 3*/
CREATE TABLE dbo.Employees
(
ID INT PRIMARY KEY,
FirstName VARCHAR(32),
LastName VARCHAR(32),
Email VARCHAR(255) -- , ...
)
/* Salaries Option 1*/
CREATE TABLE dbo.Salaries
(
EmployeeID INT,
Salary INT
)
/* Salaries Option 2*/
CREATE TABLE dbo.Salaries
(
Employee INT,
Salary INT
)
I have more experience with object oriented programing then database design. With OOP when naming properties of a class you would not want to repeat the name of the class as it would be redundant (Employee.ID not Employee.EmployeeID). Thus off hand I think Employee Option 3 and Salaries Option 1 above would be best, as this how I would name properties of classes in OOP
Am I right? Is there something else I should be considering that applies to database design that does not apply to OOP?