Sha256: c360811ad096e920e726a5ea1774293a20dadf795a28f1b928643626152a4f56

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

CREATE TABLE Company (
	-- Company is run by CEO and CEO is a kind of Manager and Manager is a kind of Employee and Employee works for Company and Company has CompanyName,
	CEOCompanyName                          varchar NOT NULL,
	-- Company is run by CEO and CEO is a kind of Manager and Manager is a kind of Employee and Employee has EmployeeNr,
	CEOEmployeeNr                           int NOT NULL,
	-- Company has CompanyName,
	CompanyName                             varchar NOT NULL,
	PRIMARY KEY(CompanyName)
)
GO

CREATE TABLE Employee (
	-- Employee works for Company and Company has CompanyName,
	CompanyName                             varchar NOT NULL,
	-- Employee has EmployeeNr,
	EmployeeNr                              int NOT NULL,
	-- maybe Employee reports to Manager and Manager is a kind of Employee and Employee works for Company and Company has CompanyName,
	ManagerCompanyName                      varchar NULL,
	-- maybe Employee reports to Manager and Manager is a kind of Employee and Employee has EmployeeNr,
	ManagerEmployeeNr                       int NULL,
	PRIMARY KEY(CompanyName, EmployeeNr),
	FOREIGN KEY (CompanyName) REFERENCES Company (CompanyName),
	FOREIGN KEY (ManagerCompanyName, ManagerEmployeeNr) REFERENCES Employee (CompanyName, EmployeeNr)
)
GO

ALTER TABLE Company
	ADD FOREIGN KEY (CEOCompanyName, CEOEmployeeNr) REFERENCES Employee (CompanyName, EmployeeNr)
GO

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activefacts-examples-1.8.0 sql/server/Supervision.sql
activefacts-examples-1.7.2 sql/server/Supervision.sql
activefacts-examples-1.7.1 sql/server/Supervision.sql