• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

SQL

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the problem statement is :

The database :

Emp(eid: integer, ename: string, age: integer , salary: real)
Works(eid: integer, did: integer, pct time: integer)
Dept(did: integer, budget: real , managerid: integer)

Query :. Define a table constraint on Dept that will ensure that all managers have age > 30


and the solution i tried is:


CREATE TABLE Dept ( did INTEGER,

buget REAL ,

managerid INTEGER ,

PRIMARY KEY (did),

FOREIGN KEY (managerid) REFERENCES Emp,

CHECK( ( SELECT E.age FROM Emp E, Dept D)

WHERE E.eid = D.managerid ) > 30 ))





but it's not working , giving error as

Subquery not allowed here .

What may b the problem in this solution ?
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The general Syntax of check constrain is ,
So I guess the following should work
[ August 23, 2006: Message edited by: Srinivasa Raghavan ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic