How do you convert an ER diagram to tables?
Converting an ER diagram to a relational schema, or ER to relational mapping, turns each entity, attribute and relationship of a conceptual model into tables, columns, primary keys and foreign keys. Textbooks give it as a short algorithm with one rule per kind of ER construct, and the rules leave little to taste: the cardinality and participation on the diagram decide where each foreign key goes and whether it allows NULL.
A Chen diagram is a conceptual-level diagram: entities, attributes and relationships, with many-to-many left unresolved and no foreign keys. A logical model resolves each many-to-many and adds the foreign keys, which is what the mapping does.
The rules, in the order this post applies them:
- A strong entity becomes a table, and its key attribute the primary key.
- A 1:N relationship becomes a foreign key on the N side.
- A 1:1 relationship becomes a unique foreign key, or a primary key that is also the foreign key (a shared key).
- An M:N relationship becomes a table of its own, keyed by both sides.
- A weak entity becomes a table whose primary key holds its owner’s key.
- A multivalued attribute becomes a table of its own, keyed by the owner and the value.
- A recursive 1:N relationship becomes a foreign key from a table to itself; a recursive M:N becomes a junction table with two foreign keys to it.
The example is a small HR database: departments, employees and their managers, badges, projects, dependents and skills. It shares departments, employees and managers with the employee management system template. Each step starts from the piece of the Chen diagram it maps and ends with the SQL Server script and the tables it makes. The scripts run in order on one database.
Step 1: each strong entity becomes a table
A strong entity has a key of its own. Chen draws it as a rectangle with its attributes in ovals and the key attribute underlined . The company has three:

Each rectangle becomes a table, each oval a column, and the underlined attribute the primary key. A composite attribute such as an employee’s Name gets no column of its own; its parts, FirstName and LastName, do.
CREATE TABLE dbo.Department ( DepartmentId int NOT NULL CONSTRAINT PK_Department PRIMARY KEY, Name nvarchar(50) NOT NULL CONSTRAINT AK_Department_Name UNIQUE ); CREATE TABLE dbo.Employee ( EmployeeId int NOT NULL CONSTRAINT PK_Employee PRIMARY KEY, FirstName nvarchar(50) NOT NULL, LastName nvarchar(50) NOT NULL, HiredOn date NOT NULL ); CREATE TABLE dbo.Project ( ProjectId int NOT NULL CONSTRAINT PK_Project PRIMARY KEY, Name nvarchar(100) NOT NULL );

Every line from here on is a foreign key column added to one of these tables, or a new table.
Steps 2 and 3: 1:N and 1:1 relationships become foreign keys
Step 2: 1:N puts the foreign key on the N side
A department has many employees, and each employee works for one department. The double line on the employee’s side is total participation: every employee works for some department.

An employee row can hold one department’s key, but a department row can’t hold a list of employees, so the key goes to the N side. Total participation makes it NOT NULL:
ALTER TABLE dbo.Employee ADD DepartmentId int NOT NULL CONSTRAINT FK_Employee_Department_DepartmentId REFERENCES dbo.Department (DepartmentId);

INSERT INTO dbo.Department (DepartmentId, Name) VALUES (1, N'Engineering'), (2, N'Finance'); INSERT INTO dbo.Employee (EmployeeId, FirstName, LastName, HiredOn, DepartmentId) VALUES (10, N'Maya', N'Chen', '2019-03-04', 1), (11, N'Leo', N'Park', '2022-08-15', 1), (12, N'Ana', N'Ruiz', '2021-01-11', 2); INSERT INTO dbo.Employee (EmployeeId, FirstName, LastName, HiredOn) VALUES (13, N'Tom', N'Berg', '2026-02-02');
Msg 515, Level 16, State 2, Line 8
Cannot insert the value NULL into column 'DepartmentId', table 'Company.dbo.Employee'; column does not allow nulls. INSERT fails.
The statement has been terminated.Three employees go in. Tom has no department, and Msg 515 stops him: the double line holds. A single line , partial participation, would make the column nullable instead. An attribute of a 1:N relationship, such as the date someone joined the department, goes on the same side as the foreign key.
Step 3: 1:1 puts a unique foreign key on the total side
Each employee holds at most one badge, and each badge belongs to exactly one employee:

The foreign key could sit on either side. On the side with total participation, the badge, it can be NOT NULL, and a unique constraint caps it at one badge per employee:
CREATE TABLE dbo.Badge ( BadgeId int NOT NULL CONSTRAINT PK_Badge PRIMARY KEY, EmployeeId int NOT NULL, IssuedOn date NOT NULL, CONSTRAINT AK_Badge_EmployeeId UNIQUE (EmployeeId), CONSTRAINT FK_Badge_Employee_EmployeeId FOREIGN KEY (EmployeeId) REFERENCES dbo.Employee (EmployeeId) );

On the employee’s side the column would be NULL for everyone without a badge, and SQL Server’s unique constraint lets only one NULL in. The one-to-one relationship post shows that catch and its fix. If a badge had no number of its own, EmployeeId could be its whole primary key instead: the shared key.
Step 4: an M:N relationship becomes a table of its own
An employee works on several projects, and a project has several employees. The hours belong to the pair, so Chen hangs them on the diamond :

No foreign key column can hold this. Put ProjectId on dbo.Employee and an employee gets one project; put EmployeeId on dbo.Project and a project gets one employee. So the relationship becomes a junction table: one row for each pair, a foreign key to each side, and the pair as its primary key. The diamond’s attribute becomes a column of that table:
CREATE TABLE dbo.EmployeeProject ( EmployeeId int NOT NULL, ProjectId int NOT NULL, HoursPerWeek decimal(4,1) NOT NULL, CONSTRAINT PK_EmployeeProject PRIMARY KEY (EmployeeId, ProjectId), CONSTRAINT FK_EmployeeProject_Employee_EmployeeId FOREIGN KEY (EmployeeId) REFERENCES dbo.Employee (EmployeeId), CONSTRAINT FK_EmployeeProject_Project_ProjectId FOREIGN KEY (ProjectId) REFERENCES dbo.Project (ProjectId) );

The M:N is now two one-to-many lines: an employee has zero or more rows here, and so does a project. The primary key keeps a pair from going in twice.
Steps 5 and 6: tables keyed by their owner
Step 5: a weak entity takes its owner’s key
A dependent, a child or spouse on an employee’s benefits plan, has no key of its own: “Sofia” means nothing until you say whose dependent she is. Chen draws a double rectangle , a double diamond to the owner, and a dashed underline under the partial key:

The table’s primary key is the owner’s key plus the partial key, (EmployeeId, Name), and EmployeeId is also the foreign key, so the relationship is identifying. The weak entity post goes further into that bond.
CREATE TABLE dbo.Dependent ( EmployeeId int NOT NULL, Name nvarchar(50) NOT NULL, Relation nvarchar(20) NOT NULL, BornOn date NOT NULL, CONSTRAINT PK_Dependent PRIMARY KEY (EmployeeId, Name), CONSTRAINT FK_Dependent_Employee_EmployeeId FOREIGN KEY (EmployeeId) REFERENCES dbo.Employee (EmployeeId) ON DELETE CASCADE );

With ON DELETE CASCADE, deleting an employee deletes their dependents in the same statement: a dependent can’t outlive its owner.
Step 6: a multivalued attribute gets its own table
An employee has several skills. A double oval marks an attribute that holds a set of values:

A column holds one value, so the set moves into a table of its own: one row per employee and skill, the pair as the primary key, the employee’s key also the foreign key.
CREATE TABLE dbo.EmployeeSkill ( EmployeeId int NOT NULL, Skill nvarchar(50) NOT NULL, CONSTRAINT PK_EmployeeSkill PRIMARY KEY (EmployeeId, Skill), CONSTRAINT FK_EmployeeSkill_Employee_EmployeeId FOREIGN KEY (EmployeeId) REFERENCES dbo.Employee (EmployeeId) );

INSERT INTO dbo.EmployeeSkill (EmployeeId, Skill) VALUES (11, N'SQL'), (11, N'Python'), (12, N'SQL'); INSERT INTO dbo.EmployeeSkill (EmployeeId, Skill) VALUES (11, N'SQL');
Msg 2627, Level 14, State 1, Line 3
Violation of PRIMARY KEY constraint 'PK_EmployeeSkill'. Cannot insert duplicate key in object 'dbo.EmployeeSkill'. The duplicate key value is (11, SQL).
The statement has been terminated.Leo’s two skills and Ana’s one go in. Adding the skill SQL for Leo a second time fails on PK_EmployeeSkill with Msg 2627. Columns Skill1, Skill2 and Skill3 on dbo.Employee would cap the count at three and let the same skill in twice. Once a skill needs facts of its own, a description or a level, it has become an entity, and this table turns into step 4’s M:N: a dbo.Skill with its own key, and dbo.EmployeeSkill pointing at it.
Step 7: a recursive relationship points back at its own table
A manager is an employee too. Chen draws this recursive relationship as one diamond with both lines on the same rectangle , and role names on the lines say which end is which:

It is 1:N, so step 2’s rule applies: the foreign key goes on the N side, the report, which is the same table. The column takes the role’s name, ManagerId, since the table’s own key already has EmployeeId, and it allows NULL because someone sits at the top:
ALTER TABLE dbo.Employee ADD ManagerId int NULL CONSTRAINT FK_Employee_Employee_ManagerId REFERENCES dbo.Employee (EmployeeId);

A recursive M:N, such as employees who review several colleagues and are reviewed by several, maps by step 4’s rule: a junction table whose two foreign keys both point at dbo.Employee, one of them under a role name. What SQL Server checks and refuses on a key like ManagerId, the cascade included, is in the unary relationship post.
How ERDsmith helps
Each step ended on the same few questions about a column: which table holds it, whether it allows NULL, whether it is unique, whether it sits in the primary key. A Chen diagram leaves them open; a physical model has to answer them. ERDsmith works at that level. It draws tables and keys in crow’s foot or IDEF1X, not Chen’s rectangles and diamonds , and every line follows from the columns behind it:
- Steps 4 to 6 put a parent’s key inside the new table’s primary key, and that alone makes the relationship identifying:
dbo.EmployeeProject,dbo.Dependentanddbo.EmployeeSkillhang on solid lines . - A non-identifying relationship is optional exactly when its columns allow NULL:
ManagerIdgets a ring at its parent end,DepartmentIddoesn’t. - A self-reference stays non-identifying, and its column keeps a role name, as
ManagerIddoes forEmployeeId.