Re: DB design basic question

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: --CELKO-- (jcelko212_at_earthlink.net)
Date: 01/15/05


Date: 15 Jan 2005 06:45:10 -0800

CREATE TABLE ManagerAssignments
(mgr_emp_id INTEGER NOT NULL PRIMARY KEY
REFERENCES Personnel(emp_id)
ON UPDATE CASCADE
ON DELETE CASCADE,
dept_nbr INTEGER NOT NULL
REFERENCES Departments(dept_nbr)
ON UPDATE CASCADE
ON DELETE CASCADE,
..);

The primary key could also be on the department number, so you can pick
which way gives you the best performance. You can now add other
constraints to this table that have to do with a department manager,
add a trigger to be sure all departments have a manager, etc..



Relevant Pages

  • Re: object model to table design mapping problem
    ... the INCITS H2 Database Standards Committee(nee ANSI X3H2 ... NOT NULL PRIMARY KEY, ... REFERENCES Courses, ... ON UPDATE CASCADE ...
    (microsoft.public.sqlserver.programming)
  • Re: String Search
    ... Sample data is also a good idea, ... (proj_nbr INTEGER NOT NULL PRIMARY KEY, ... ON UPDATE CASCADE ... REFERENCES Projects ...
    (microsoft.public.sqlserver.programming)
  • Re: Design for Category Feature
    ... surname VARCHAR NOT NULL, ... REFERENCES ContactCategories ... ON UPDATE CASCADE ... PRIMARY KEY ); ...
    (comp.databases)
  • Re: Selecting several types
    ... Please post DDL, so that people do not have to guess what the keys, ... NOT NULL PRIMARY KEY, --let's use GTIN ... ON UPDATE CASCADE, ... REFERENCES ItemTypes ...
    (comp.databases.ms-sqlserver)
  • Re: Cascading update on primary key
    ... primary key depends on one of the 2 secondary tables. ... (mom CHAR(5) ... REFERENCES Mothers ... ON UPDATE CASCADE, ...
    (microsoft.public.sqlserver.programming)