Re: Altering Table - Adding Primary Key With References

From: Sietse Wijnker (sietse.wijnker_at_ATsw-software.nl)
Date: 09/02/04

  • Next message: Anders Altberg: "Re: Altering Table - Adding Primary Key With References"
    Date: Thu, 2 Sep 2004 23:48:31 +0200
    
    

    Hi Mikhail,

    You are (and i was) overlooking some additional clauses of the CREATE TABLE
    command.
    <some clauses snipped out/>
    CREATE TABLE | DBF TableName1 [NAME LongTableName] [FREE]
        ( FieldName1 FieldType [( nFieldWidth [, nPrecision] )] [NULL | NOT
    NULL]
        [, FieldName2 ... ]
        [, PRIMARY KEY eExpression2 TAG TagName2]
        [, FOREIGN KEY eExpression4 TAG TagName4 REFERENCES TableName3 [TAG
    TagName5]])

    the same goes for the ALTER TABLE command
    <some clauses snipped out/>
    ALTER TABLE TableName1
       [ADD PRIMARY KEY eExpression3 [FOR lExpression4] TAG TagName2
       [ADD FOREIGN KEY [eExpression5] [FOR lExpression6] TAG TagName4
    REFERENCES TableName2 [TAG TagName5]]

    Sample code:
    Parent table testparent references testchild through use of the index on
    tch_tpr_ifk (TAG tpr_ifk)

    CREATE TABLE testParent (;
     tpr_ipk_longerthan10 I AUTOINC, ;
     tpr_cvalue C(10), ;
     PRIMARY KEY tpr_ipk_longerthan10 TAG tpr_ipk)

    CREATE TABLE testChild (;
     tch_ipk I AUTOINC, ;
     tch_tpr_ifk I, ;
     tch_cvalue C(10), ;
     PRIMARY KEY tch_ipk TAG tch_ipk, ;
     FOREIGN KEY tch_tpr_ifk TAG tpr_ifk REFERENCES testParent TAG tpr_ipk )

    Regards,
    Sietse Wijnker

    "Mikhail" <Mikhail@discussions.microsoft.com> wrote in message
    news:EAAF4F42-E926-42BF-9463-1D07616070D3@microsoft.com...
    > You don't understand me, may be because my english is not so good :-)
    >
    > In identity relashionship primary key from parent table migrate in child
    > table as primary key.
    >
    > VFP:
    >
    > If in parent table field name for PK not longer 10 char's i can use
    > following code:
    >
    > CREATE TABLE ChildTable ( ;
    > ChildTablePrimaryKey I PRIMARY KEY REFERENCES ParentTable, ;
    > ....
    > )
    > but if name of field is longer 10 char's a erro? "Tag Name is too long"
    > is
    > occured.
    >
    > In next example i can specify TAG for PRIMARY KEY but can't specify
    > REFRENCE
    >
    > CREATE TABLE ChildTable ( ;
    > ChildTablePrimaryKey I, ;
    > ....
    > PRIMARY KEY ChildTablePrimaryKey TAG ChildTabPK
    > )
    >
    > In ALTER TABLE command works similarly.
    >


  • Next message: Anders Altberg: "Re: Altering Table - Adding Primary Key With References"

    Relevant Pages

    • Re: Altering Table - Adding Primary Key With References
      ... The CREATE TABLE command work fine. ... > let the primary key of the Child table be the referecing field. ... > can't do it with the ALTER TABLE command in VFP8. ... > ALTER TABLE Morechildren ADD FOREIGN KEY cid TAG cid1 REFERENCES Parents ...
      (microsoft.public.fox.vfp.dbc)
    • how to recreate indexes?
      ... I wanted to implement index recreation approach: ... ALTER TABLE 'CERT_TYPES' ADD PRIMARY KEY BINTOCTAG CERT_TYPE ...
      (microsoft.public.fox.helpwanted)
    • Re: Altering Table - Adding Primary Key With References
      ... I think you're expecting too much functionality from the command ... This clause in the alter table command gives you the possibility to add a ... PRIMARY KEY in the CREATE TABLE command also sets the field as a primairy ... Relations between tables can be defined in the database but they are not ...
      (microsoft.public.fox.vfp.dbc)
    • Re: [PATCH] hpsa: SCSI driver for HP Smart Array controllers
      ... Can we just use lists for command management? ... Bit maps are generally more efficient than lists since we touch less data. ... Maybe just add some wrapper around some of blk_queue_start_tag that takes a the bqt and allocates the tag. ... the request queue for the device ...
      (Linux-Kernel)
    • Re: [PATCH] hpsa: SCSI driver for HP Smart Array controllers
      ... Can we just use lists for command management? ... Bit maps are generally more efficient than lists since we touch less data. ... In that patch where does the tag come from? ... the request queue for the device ...
      (Linux-Kernel)