Search Postgresql Archives

constrains on two tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

Here is my table:

Table School
(
    id integer,
    name text
);

Table Department
(
    id integer,
    school_id integer reference school(id),
    name text
);

Table Course
(
    department_id integer references department(id),
    name text,
    course_number text
)

I would like to make the course_number unique, but not in the course
table, nor in department. I would like to make the course_number
unique in the scope of School. So, you may see the same course_number
in Course table, but (school_id, course_number) should be always
unique. How can I make the constrain?

Thanks,

ff


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux