Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: does a table always need a PK?

Re: does a table always need a PK?

From: --CELKO-- <joe.celko_at_northface.edu>
Date: 23 Aug 2003 15:44:15 -0700
Message-ID: <a264e7ea.0308231444.3179b3a3@posting.google.com>


>> do I need to have a primary key in the BOOK table? <<

Yes, otherwise it is not a table by definition. Assuming that you have more than one book, use the ISBN as the industry standard identifier and use this table:

CREATE TABLE Books
(isbn CHAR(10) NOT NULL,
 page_nbr INTEGER NOT NULL,
 content TEXT NOT NULL,
 PRIMARY KEY (isbn, page_nbr));

if you had only one book, use its title for the table name:

CREATE TABLE "Moby Dick"
(page_nbr INTEGER NOT NULL PRIMARY KEY,
 content TEXT NOT NULL);

You are splitting attributes in the original schema. That is, you put the attributes of a book in (n > 1) table, so the data model was not complete. Received on Sat Aug 23 2003 - 17:44:15 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US