Get startedGet started for free

Creating entities for ER model

The HR department has requested a new system to track the training programs employees have completed.

Your task involves applying the ER model by setting up a new entity to record the details of each session, including a reference to the training program from the trainings entity.

This exercise is part of the course

Introduction to Data Modeling in Snowflake

View Course

Exercise instructions

  • Create a new entity called employee_training_details that will store records of training sessions attended by employees.
  • This entity should include an employee_training_id as a primary key; the datatype should be NUMBER(10,0).
  • Add a new attribute year with datatype NUMBER(4,0) to record the year that the employee took the training.
  • Include foreign keys that reference employee_id in the employees entity and training_id in the training entity; both are NUMBER(38,0) data types.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

-- Create new entity
___ employee_training_details (
  	-- Assign a unique identifier for the entity
	___ ___ PRIMARY KEY,
  	-- Add new attribute
    ___,
  	-- Add new attributes to reference foreign entities
  	___ NUMBER(38,0),
    ___ NUMBER(38,0),
    ___ (___) ___ employees(employee_id),
    ___ (___) ___ trainings(training_id)
);
Edit and Run Code