Results 1 to 4 of 4

Thread: 2 tables with no primary key

  1. #1
    Junior Member
    Join Date
    Oct 2007
    Answers
    3

    2 tables with no primary key

    I have a database containing 5 tables. I have 2 tables with foreign key but no primary key does it work or not?


  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: 2 tables with no primary key

    a foreign key is a referential constraint between two tables. The foreign key identifies a column or a set of columns in one (referencing) table that refers to a column or set of columns in another (referenced) table. The columns in the referencing table must form a primary key or unique key in the referenced table

    If referenced table contains unique key and referencing table referes that (unique key) key then it works

    simple example

    create table emp (
    empno number ,
    deptno number references emp15(empno), -- references itself
    empname varchar2(20),
    CONSTRAINT key_unique UNIQUE(empno)
    )


  3. #3
    Junior Member
    Join Date
    Jan 2008
    Answers
    1

    Re: 2 tables with no primary key

    Yah it can work


  4. #4
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: 2 tables with no primary key

    Quote Originally Posted by susarlasireesha View Post
    a foreign key is a referential constraint between two tables. The foreign key identifies a column or a set of columns in one (referencing) table that refers to a column or set of columns in another (referenced) table. The columns in the referencing table must form a primary key or unique key in the referenced table

    If referenced table contains unique key and referencing table referes that (unique key) key then it works

    simple example

    create table emp (
    empno number ,
    deptno number references emp15(empno), -- references itself
    empname varchar2(20),
    CONSTRAINT key_unique UNIQUE(empno)
    )
    In above post pls change emp15 as emp
    create table emp (
    empno number ,
    deptno number references emp(empno), -- references itself
    empname varchar2(20),
    CONSTRAINT key_unique UNIQUE(empno)
    )


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact