Re: SQL Database design question

From: Neo <neo55592_at_hotmail.com>
Date: 28 Jan 2005 10:32:55 -0800
Message-ID: <1106937175.536020.39970_at_z14g2000cwz.googlegroups.com>


> Is it better to create a new EmployeeBranch ... or create several columns in the Employee table

Add EmployeeBranch table. If db doesn't implement desired constraint, add in code. In script below for a small/simple experimental db, each employee can work at 0 to many branches.

// Create items in directory to classify things.
(CREATE *employee.item ~in = dir)
(CREATE *intern.item ~in = dir)
(CREATE *temporary.item ~in = dir)
(CREATE *branch.item ~in = dir)
(CREATE *code.item ~in = dir)

// Create the verb 'works at'.
(CREATE *worksAt.cls = verb)

// Create intern John who works at research branch.
(CREATE *john.cls = employee)
(CREATE john.cls= intern)
(CREATE john.code = +JOHN_I_123)
(CREATE john.worksAt = +research)

// Create temp Mary who works at research and mfg plant 10 with a code.
(CREATE *mary.cls = employee)
(CREATE mary.cls = temporary)
(CREATE mary.code = +MARY_T_303)
(CREATE mary.worksAt = +research)
(CREATE mary.worksAt = (CREATE *mfg plant 10.cls=branch & it.code=
+MFG_PLT_10))

// Find temporary employee(s)
// who work at a branch whose code is MFG_PLT_10.
// Finds Mary.

(SELECT %.cls=employee & %.cls=temporary & %.worksAt=(%.cls=branch &
%.code=MFG_PLT_10)) Received on Fri Jan 28 2005 - 19:32:55 CET

Original text of this message