Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2007
    Posts
    1

    Unanswered: needs help in designing a very simple database

    Hi,
    I am a student and i need your help in solving an assignment. I have been asked to create a recursive entity for employee with five attributes. employee id, name, designation, dept and name of supervisor. The values in the supervisor field would be the foreign key for employee id in the same table. The supervisor id cannot be null. Now, the problem is that the CEO of the company doesn't have a supervisor but as the field is set to not null. Some value must be entered in this field for supervisor as well. Please tell me the solution.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    by having it point to itself?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    this is an assignment? and they flat out told you that supervisorid cannot be null?

    dude, they are so, so wrong

    here's what you should hand in as the answer: the assignment is impossible, because you can never add the first row -- since supervisorid cannot be null, it must point to an existing row, but since there is no row yet, the first insert will always fail

    expect a mark of either 100% or 0%, and if it is the latter, you may rest assured that it is out of spite because you proved that the guy who wrote the test never heard of a fundamental concept called relational integrity

    Q, as the saying goes, E D
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Everyone is entitled to their own opinion, regardless of how valid (or not) it may be.
    Code:
    SQL> create table employees
      2  ( emp_id      number not null constraint pk_emp_id primary key ,
      3    emp_name    varchar2(48),
      4    designation varchar2(32),
      5    department  varchar2(24),
      6    sup_id      number not null) ;
    
    Table created.
    
    SQL> insert into employees values(1,'BIG WIG','CEO','NUMBER_1',1);
    
    1 row created.
    
    SQL> alter table employees add constraint fk_sup_id foreign key (sup_id) references employees (emp_id);
    
    Table altered.
    
    SQL> insert into employees values(2,'Little Cheese','SR VP','SALES',1);
    
    1 row created.
    Does this implementation meet the design requirements?
    Last edited by anacedent; 02-13-07 at 20:22.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •