English 中文(简体)
页: 1
原标题:SQL - enforce constraints between tables
  • 时间:2012-01-15 19:54:39
  •  标签:
  • sql

我想以“工厂”管理人员访问的模式。

我有4个制约因素想要执行:

  1. 在任何访问中,有一位参加此次访问的管理人员

  2. manager can visit in the same factory more that one time, but in diffrent days.

  3. 管理人员可以在白天访问许多工厂。

  4. 一次访问可在工厂进行,最多。

下面表一是:

visit-Factory(Name Factory, date, during, summary)
\where Name Factory, date are PK

visit-manager(Name Factory, data, manager)
\ where Name Factory, date, manager are pk

This enforce the 3 last, but the first is not enforced.

任何想法? 增 编

问题回答

在良好的数据库设计中,你需要确保数据至少重复。

有鉴于此,审视你目前的设计,看看你可以消除这种重复。

我不知道你们是否了解了各实体以及如何模仿这些实体,但如果是,我想到的是你们所需要的不同实体。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...