Syntax for creating foreign key across users in a database

There are two user present A,B.They are granted all privileges.Now in USER A, there is a table PARENT whose primary key is PARENT_NO.In USER B I have created a table CHILD whose primary key is CHILD_NO.
In the CHILD table of USER B, I want to create a foreign key relation to the PARENT table of USER A.For this I have created a column CHILD_PARENT_NO in the CHILD table.If anybody knows the syntax please post the syntax for creating the required foreign key relationship?

Please post your code. Cut'n'paste from SQL*Plus like this...
SQL> conn a/a
Connected.
SQL> desc t1
Name                                      Null?    Type
COL1                                               NUMBER
COL2                                               VARCHAR2(10)
SQL> grant references on t1 to b;
Grant succeeded.
SQL> conn b/b
SQL> create synonym a_t for a.t1;
Synonym created.
SQL> alter table test add constraint fk foreign key (n) references a_t(col1);
Table altered.
SQL> Note that Oracle will translate the synonym anyway...
SQL> select constraint_name, r_owner, r_constraint_name
  2  from  user_constraints
  3  where table_name = 'TEST'
  4  /
CONSTRAINT_NAME R_OWNER R_CONSTRAINT_NAME
FK              A       T1_PK
SQL> By the way, this ...
GRANT ALL PRIVILEGES TO B;... is a mindbendingly unsafe way of proceeding. In real life you would have given user B the power to utterly destroy your database. It's always easier to start with good habits than to break bad ones so please get used to granting only the minimum set of privileges necessary.
Cheers, APC

Similar Messages

  • Unable to create foreign key: InvalidArgument=Value of '0' is not valid for 'index'. Parameter name: index

    I am running an SQL(CE) script to create a DB. All script commands succeed, but the DB get "broken" after creating the last costaint: after running the script, viewing table properties of Table2 and clicking on "Manage relations" gives the following error: Unable to create foreign key: InvalidArgument=Value of '0' is not valid for 'index'. Parameter name: index. Wondering what does that refer to...
    Here it is the script. Please note that no error is thrown by running the following queries (even from code that passing the queries by hand, one-by-one to sql server management studio).
    CREATE TABLE [table1] (
    [id_rubrica] numeric(18,0) NOT NULL
    , [id_campo] numeric(18,0) NOT NULL
    , [nome] nvarchar(100) NOT NULL
    GO
    ALTER TABLE [table1] ADD PRIMARY KEY ([id_rubrica],[id_campo]);
    GO
    CREATE UNIQUE INDEX [UQ__m_campi] ON [table1] ([id_campo] Asc);
    GO
    CREATE TABLE [table2] (
    [id_campo] numeric(18,0) NOT NULL
    , [valore] nvarchar(4000) NOT NULL
    GO
    ALTER TABLE [table2] ADD PRIMARY KEY ([id_campo],[valore]);
    GO
    ALTER TABLE [table2] ADD CONSTRAINT [campo_valoriFissi] FOREIGN KEY ([id_campo]) REFERENCES [table1]([id_campo]);
    GO
    Sid (MCP - http://www.sugata.eu)

    I know this is kind of old post, but did this realy solved your problem?
    I'm getting this same error message after adding a FK constraint via UI on VS2008 Server Explorer.
    I can add the constraint with no errors, but the constraint is not created on the DataSet wizard (strongly typed datasets on Win CE 6) and when I click "Manage Relations" on the "Table Properties" this error pop out:
    "InvalidArgument=Value or '0' is not valid for 'index'.
    Parameter name: index"
    Even after vreating my table with the relation in SQL the same occurs:
    CREATE TABLE pedidosRastreios (
        idPedidoRastreio INT NOT NULL IDENTITY PRIMARY KEY,
        idPedido INT NOT NULL CONSTRAINT FK_pedidosRastreios_pedidos REFERENCES pedidos(idPedido) ON DELETE CASCADE,
        codigo NVARCHAR(20) NOT NULL

  • How to create foreign key automatically?

    I am writing to seek help, in regards creating foreign key automatically, when I insert data into my ''price'' table.  I have 2 tables, one called prices and names.  the relationship between them, if that one name can have many prices and one price
    can have many names (many-to-many). Hence, i have junction table called  "Name_Prices", as shown below in the sample database schema:
    Names
    name_id [pk]
    name
    type
    UploadDate
    Prices
    Price_id [pk]
    name_id [fk]
    price
    uploadDate
    Name_Prices
    name_id REFERENCE names (name_id)
    price_id REFERENCE prices (price_id)
    PRIMARY KEY (name_id, price_id)
    The  price's data input comes in as CSV file everyday. (please see the example below) :
    name name_type price UploadDate
    ALBA MBS 93.5 17/10/2014
    ALESC Trup 58 17/10/2014
    ALESC Trup 52 17/10/2014
    My desire goal/output is to be able to create a functionality, where I can insert the price's data into the database (''prices''), it will automatically insert foreign key in the price
    table (from the names table), and if there is a new price's name, then the database will create a new name id for it, in the name's table, transferring the name, its type, from the CSV input data. 
    In order to achieve this task, where would I start implementing this logic?(in SQL server or application-side) what steps does this involve and is this task achievable, all in sql server side (i.e. store procedure, functions etc..). 
    Apology in advance, if the question is not clear to understand, i happy to follow up with further questions, if required.  
    Any help would be very appreciated. Many thanks

    As noted above, I modified the design:
    Products
    Product_id [pk]
    Product
    type
    UploadDate
    Prices
    Price_id [pk]
    price
    uploadDate
    Product_Prices
    Product_id REFERENCE Products (Product_id)
    price_id REFERENCE prices (price_id)
    PRIMARY KEY (Product_id, price_id)
    Note
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Is it possible to create foreign key from composite key in other table.

    SQL> desc PRODUCT_CONFIG_OPTION;
    Name Null? Type
    CONFIG_ITEM_ID NOT NULL VARCHAR2(20) --composite primary key
    CONFIG_OPTION_ID NOT NULL VARCHAR2(20) --composite primary key
    CONFIG_OPTION_NAME VARCHAR2(100)
    DESCRIPTION VARCHAR2(255)
    SEQUENCE_NUM NUMBER(18)
    LAST_UPDATED_STAMP TIMESTAMP(6)
    LAST_UPDATED_TX_STAMP TIMESTAMP(6)
    CREATED_STAMP TIMESTAMP(6)
    CREATED_TX_STAMP TIMESTAMP(6)
    SQL> DESC PRODUCT_CONFIG_ITEM;
    Name Null? Type
    CONFIG_ITEM_ID NOT NULL VARCHAR2(20)
    CONFIG_ITEM_TYPE_ID VARCHAR2(20)
    CONFIG_ITEM_NAME VARCHAR2(100)
    DESCRIPTION VARCHAR2(255)
    LONG_DESCRIPTION CLOB
    IMAGE_URL VARCHAR2(255)
    LAST_UPDATED_STAMP TIMESTAMP(6)
    LAST_UPDATED_TX_STAMP TIMESTAMP(6)
    CREATED_STAMP TIMESTAMP(6)
    CREATED_TX_STAMP TIMESTAMP(6)
    SQL> desc product;
    Name Null? Type
    PRODUCT_ID NOT NULL VARCHAR2(20)
    PRODUCT_TYPE_ID VARCHAR2(20)
    PRIMARY_PRODUCT_CATEGORY_ID VARCHAR2(20)
    MANUFACTURER_PARTY_ID VARCHAR2(20)
    FACILITY_ID VARCHAR2(20)
    INTRODUCTION_DATE TIMESTAMP(6)
    SUPPORT_DISCONTINUATION_DATE TIMESTAMP(6)
    SALES_DISCONTINUATION_DATE TIMESTAMP(6)
    SALES_DISC_WHEN_NOT_AVAIL CHAR(1)
    INTERNAL_NAME VARCHAR2(255)
    BRAND_NAME VARCHAR2(100)
    COMMENTS VARCHAR2(255)
    =========
    CREATE TABLE PROD_CONFIG_PROD_CONFIG_OPTION (
    PRODUCT_ID VARCHAR2(20),
    CONFIG_ITEM_ID VARCHAR2(20),
    CONFIG_OPTION_ID VARCHAR2(20),
    PAGE_NUM_TO NUMBER(18),
    ALTERNATE_PAGE_NUM_TO1 NUMBER(18),
    ALTERNATE_PAGE_NUM_TO2 NUMBER(18),
    ALTERNATE_PAGE_NUM_TO3 NUMBER(18),
    LAST_UPDATED_STAMP TIMESTAMP(6),
    LAST_UPDATED_TX_STAMP TIMESTAMP(6),
    CREATED_STAMP TIMESTAMP(6),
    CREATED_TX_STAMP TIMESTAMP(6),
    CONSTRAINT PK_PROD_CAT_CONFIG_MOD PRIMARY KEY (PRODUCT_ID),
    CONSTRAINT FK_PRODUCT_ID FOREIGN KEY (PRODUCT_ID) REFERENCES PRODUCT(PRODUCT_ID),
    CONSTRAINT FK_CONFIG_ITEM_ID FOREIGN KEY (CONFIG_ITEM_ID) REFERENCES PRODUCT_CONFIG_ITEM(CONFIG_ITEM_ID),
    CONSTRAINT FK_CONFIG_OPTION_ID FOREIGN KEY (CONFIG_OPTION_ID) REFERENCES PRODUCT_CONFIG_OPTION(CONFIG_OPTION_ID) )
    TABLESPACE DATA_SMALL
    i try to create this table if i omit 3rd foreign key constraint then table successfully created.but including trd foreign key constraint it return error "ORA-02270: no matching unique or primary key for this column-list"
    i checked everything is it possible to create foreign key from composite key in other table.

    And
    CONSTRAINT FK_CONFIG_OPTION_ID FOREIGN KEY (CONFIG_ITEM_ID,CONFIG_OPTION_ID) REFERENCES PRODUCT_CONFIG_OPTION(CONFIG_ITEM_ID,CONFIG_OPTION_ID)
    ?

  • Foreign keys without ON DELETE CASCADE; Database Design question

    This is the 3rd company i am working, where i see Foreign Keys created without
    ON DELETE CASCADEclause.
    My colleague says that it is created without ON DELETE CASCADE clause in order to make deletion of data (child records) difficult. So, for Purge/Archive codes, before we delete from Parent table we have to delete from the Child table first.
    Occasinaly , something goes wrong and we'll end up disabling all FKs and then do Purging, Archiving, etc..
    So, isn't it better to create Foreign keys with ON DELETE CASCADE clause rather than having all these hassles?
    From you experience, what do you guys think?

    ON DELETE CASCADE is usually not a good idea - something 'magical' happens in the background and rows go away. Instead, consider making the FK DEFERRABLE INITIALLY DEFERRED. That way you can delete the parent and child rows in any sequence and the constraint will not be checked until commit time. You want to use an API (stored procedure/package) to make sure DML is executed in the proper sequence and in the proper way for your business rules.

  • Create Foreign Keys between two Schemata

    Hello,
    I use Oracle 10g and I trying to create a ForeignKey constraint between two tables in different schemata.
    This is my DDL-Script
    SQL> CREATE TABLE PROJECT.LOCATION (
    ID INTEGER NOT NULL,
    MAIN INTEGER,
    KURZ VARCHAR(40),
    NAME VARCHAR(40),
    STRASSE VARCHAR(40),
    ORT VARCHAR(40),
    TELEFON VARCHAR(40),
    FAX VARCHAR(40),
    EMAIL VARCHAR(40),
    PLZ VARCHAR(40),
    CONSTRAINT PK_LOCATION PRIMARY KEY (ID)
    Tablespace PROJECT;
    CREATE TABLE Diary.Diary (
    ID INTEGER NOT NULL,
    LOCATION_ID INTEGER NOT NULL,
    CONSTRAINT PK_Diary PRIMARY KEY (ID)
    Tablespace Diary;
    ALTER TABLE Diary.Diary
    ADD CONSTRAINT FK_Diary_Has_LOCATION
    FOREIGN KEY (LOCATION_ID) REFERENCES PROJECT.LOCATION (ID);
    This is the Message that gives my SQLplus :
    SQL> ALTER TABLE Diary.Diary
    2 ADD CONSTRAINT FK_Diary_Has_LOCATION
    3 FOREIGN KEY (LOCATION_ID) REFERENCES PROJECT.LOCATION (ID);
    FOREIGN KEY (LOCATION_ID) REFERENCES PROJECT.LOCATION (ID)
    FEHLER in Zeile 3:
    ORA-00942: Tabelle oder View nicht vorhanden
    All Grants (select,alter,references) are given to the User for the tables.
    Whats then Problem?

    You miss some priviledge:
    SQL> create user project identified by project;
    Utente creato.
    SQL> grant connect, resource to project;
    Concessione riuscita.
    SQL> create user diary identified by diary;
    Utente creato.
    SQL> grant connect, resource to diary;
    Concessione riuscita.
    SQL> CREATE TABLE PROJECT.LOCATION (
      2  ID INTEGER NOT NULL,
      3  MAIN INTEGER,
      4  KURZ VARCHAR(40),
      5  NAME VARCHAR(40),
      6  STRASSE VARCHAR(40),
      7  ORT VARCHAR(40),
      8  TELEFON VARCHAR(40),
      9  FAX VARCHAR(40),
    10  EMAIL VARCHAR(40),
    11  PLZ VARCHAR(40),
    12  CONSTRAINT PK_LOCATION PRIMARY KEY (ID)
    13  )
    14  ;
    Tabella creata.
    SQL> CREATE TABLE Diary.Diary (
      2  ID INTEGER NOT NULL,
      3  LOCATION_ID INTEGER NOT NULL,
      4  CONSTRAINT PK_Diary PRIMARY KEY (ID)
      5  )
      6  ;
    Tabella creata.
    SQL> ALTER TABLE Diary.Diary
      2  ADD CONSTRAINT FK_Diary_Has_LOCATION
      3  FOREIGN KEY (LOCATION_ID) REFERENCES PROJECT.LOCATION (ID);
    FOREIGN KEY (LOCATION_ID) REFERENCES PROJECT.LOCATION (ID)
    ERRORE alla riga 3:
    ORA-00942: tabella o vista inesistente
    -- DIARY CAN'T SEE PROJECT.LOCATION
    SQL> grant select on project.location to diary;
    Concessione riuscita.
    SQL> ALTER TABLE Diary.Diary
      2  ADD CONSTRAINT FK_Diary_Has_LOCATION
      3  FOREIGN KEY (LOCATION_ID) REFERENCES PROJECT.LOCATION (ID);
    FOREIGN KEY (LOCATION_ID) REFERENCES PROJECT.LOCATION (ID)
    ERRORE alla riga 3:
    ORA-01031: privilegi insufficienti
    -- DIARY CAN SEE PROJECT.LOCATION BUT CAN'T REFERENCE IT
    SQL> grant references on project.location to diary;
    Concessione riuscita.
    SQL> ALTER TABLE Diary.Diary
      2  ADD CONSTRAINT FK_Diary_Has_LOCATION
      3  FOREIGN KEY (LOCATION_ID) REFERENCES PROJECT.LOCATION (ID);
    Tabella modificata.
    -- NOW IT'S ALL OK!!Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2009/12/18/table-elimination-oppure-join-elimination-lottimizzatore-si-libera-della-zavorra/]

  • Please help me to create foreign key.

    oracle 10g, using sqldbx
    I tried everything I could but all in vain,
    CREATE TABLE folder(
    folderid INT NOT NULL PRIMARY KEY,
    foldername VARCHAR(255) NOT NULL,
    createdby VARCHAR(255) NOT NULL,
    createdate TIMESTAMP NOT NULL
    CREATE TABLE document(
    documentid INT NOT NULL PRIMARY KEY,
    folderid INT NOT NULL,
    documenttitle VARCHAR(255) NOT NULL,
    documentauthor VARCHAR(255) NOT NULL,
    createdate TIMESTAMP NOT NULL
    ALTER TABLE document ADD CONSTRAINT fkdocument FOREIGN KEY (document.folderid) REFERENCES (folder.FOLDERID)
    the last statement is saying invalid folder name. Please help

    Hi,
    Welcome to the forum!
    See the SQL Language manual for the correct syntax:
    ALTER TABLE     document
    ADD CONSTRAINT      fkdocument
    FOREIGN KEY      (folderid)
    REFERENCES      folder (FOLDERID)
    ;Thanks for posting your code! That's very helpful.
    Have you seen the forum FAQ yet? {message:id=9360002}

  • Creation of Index for Primary & Foreign Key required?

    hi,
    i would like to find out if a column is defined as the primary key, do i need to create a separate index for it? or defining a primary key will tell the db to automatically create an index for it?
    does foreign key have the same behavior as the primary key constraint?
    thanks!

    i would like to find out if a column is defined as the primary key, do i need to create a separate index for it? No
    or defining a primary key will tell the db to automatically create an index for it? Yes
    See
    http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg05itg.htm#7265
    does foreign key have the same behavior as the primary key constraint?No. See http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg05itg.htm#1574

  • What is the best practice for creating primary key on fact table?

    what is the best practice for primary key on fact table?
    1. Using composite key
    2. Create a surrogate key
    3. No primary key
    In document, i can only find "From a modeling standpoint, the primary key of the fact table is usually a composite key that is made up of all of its foreign keys."
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/logical.htm#i1006423
    I also found a relevant thread states that primary key on fact table is necessary.
    Primary Key on Fact Table.
    But, if no business requires the uniqueness of the records and there is no materilized view, do we still need primary key? is there any other bad affect if there is no primary key on fact table? and any benifits from not creating primary key?

    Well, natural combination of dimensions connected to the fact would be a natural primary key and it would be composite.
    Having an artificial PK might simplify things a bit.
    Having no PK leads to a major mess. Fact should represent a business transaction, or some general event. If you're loading data you want to be able to identify the records that are processed. Also without PK if you forget to make an unique key the access to this fact table will be slow. Plus, having no PK will mean that if you want to used different tools, like Data Modeller in Jbuilder or OWB insert / update functionality it won't function, since there's no PK. Defining a PK for every table is a good practice. Not defining PK is asking for a load of problems, from performance to functionality and data quality.
    Edited by: Cortanamo on 16.12.2010 07:12

  • What's the privileges to create foreign key to a different schema.table ?

    Hi
    In my current schema I want to add a new foreign key. But this key is referencing to a table in a different schema, like this:
    Alter table some_table ADD ( Constraint FK_01 Foreign Key (L_ID) References schema.table (LL_ID));
    and getting the error - ORA-01031 insufficient privileges
    Which privileges do I need for this (At this time, I have only GRANT Select)? Any help would be much appreciated
    Best regards
    Remo

    Hi,
    You need GRANT REFERENCES object privilege to the user.
    Cheers

  • Confusion On Creating Foreign Key

    I'm confused about creating a foreign key in my table since two tables in the schema will hold identical info:
    EMP_ID
    EMP_NAME
    EMP_MANAGER
    DEPT_ID
    DEPT_NAME
    DEPT_MANAGER
    Now my 1st confusion is if I'm creating a foreign key, do I point EMP_MANAGER to DEPT_ID or DEPT_MANAGER? How can I configure the EMPLOYEES.EMP_MANAGER to pull the values from DEPARTMENT.DEPT_MANAGER? Would I need to point it to DEPT_ID for any reason or would it be a direct link between the two _MANAGER columns?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    >
    the two column names have to be exact
    >
    No! The data in the columns needs to be exact. It doesn't matter what the column names are.
    The column names you provided appear to show that YOUR emp table is denormalized. It has an EMP_MANAGER column which presumably contains the NAME of the manager, rather than the DEPT_ID of the manager. If it actually contains the NAME and the DEPT_MANAGER column of the other table has names you could create a foreign key between them.
    But that means you are duplicating the manager name in both tables. If the EMP_MANAGER column actually contains the DEPT_ID of the employees manager then create a foreign key between EMP_MANAGER and DEPT_ID.

  • How to insert value for composed foreign key?

    My problem when I update or insert to table Ffclient which has link 1-1 with other table ClientLoan by composes primary key loanId and clienId (break table). I auto mapping by Jdeveloper 10g version 10.1.2. In FfClient table has two fields compose foreign key of ClientLoan as loanId and clienId not nullable. In toplink object Ffclient it only has one reference ClientLoan object by clientLoan field, not has two fields loanId and clienId . When I insert or update to database, I can't set value for these two fields direct so I have created new ClientLoan object and set value for composed primary key loanId and clienId, after that set it to object Ffclient. But when I update or insert to database it occurs exception about insert null for two not nullable fields: loanId and clienId.
    Any one has error as mime? Any one help me correct my error.
    Thanks in advance.
    Mapping is:
    ….
    <database-mapping>
    <attribute-name>ffclientCollection</attribute-name>
    <read-only>false</read-only>
    <get-method-name>getFfclientCollection</get-method-name>
    <set-method-name>setFfclientCollection</set-method-name>
    <reference-class>uk.co.lsb.elb.toplink.Ffclient</reference-class>
    <relationship-partner-attribute-name>clientLoan</relationship-partner-attribute-name>
    <is-private-owned>false</is-private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <indirection-policy>
    <mapping-indirection-policy>
    <type>oracle.toplink.internal.indirection.TransparentIndirectionPolicy</type>
    </mapping-indirection-policy>
    </indirection-policy>
    <container-policy>
    <mapping-container-policy>
    <container-class>oracle.toplink.indirection.IndirectList</container-class>
    <type>oracle.toplink.internal.queryframework.ListContainerPolicy</type>
    </mapping-container-policy>
    </container-policy>
    <source-key-fields>
    <field>LSB.CLIENT_LOAN.CLIENT_ID</field>
    <field>LSB.CLIENT_LOAN.LOAN_ID</field>
    </source-key-fields>
    <target-foreign-key-fields>
    <field>LSB.FFCLIENT.CLIENT_ID</field>
    <field>LSB.FFCLIENT.LOAN_ID</field>
    </target-foreign-key-fields>
    <type>oracle.toplink.mappings.OneToManyMapping</type>
    </database-mapping>
    …..
    <database-mapping>
    <attribute-name>clientLoan</attribute-name>
    <read-only>false</read-only>
    <reference-class>uk.co.lsb.elb.toplink.ClientLoan</reference-class>
    <relationship-partner-attribute-name>ffclientCollection</relationship-partner-attribute-name>
    <is-private-owned>false</is-private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <indirection-policy>
    <mapping-indirection-policy>
    <type>oracle.toplink.internal.indirection.BasicIndirectionPolicy</type>
    </mapping-indirection-policy>
    </indirection-policy>
    <uses-joining>false</uses-joining>
    <foreign-key-fields>
    <field>LSB.FFCLIENT.CLIENT_ID</field>
    <field>LSB.FFCLIENT.LOAN_ID</field>
    </foreign-key-fields>
    <source-to-target-key-field-associations>
    <association>
    <association-key>LSB.FFCLIENT.LOAN_ID</association-key>
    <association-value>LSB.CLIENT_LOAN.LOAN_ID</association-value>
    </association>
    <association>
    <association-key>LSB.FFCLIENT.CLIENT_ID</association-key>
    <association-value>LSB.CLIENT_LOAN.CLIENT_ID</association-value>
    </association>
    </source-to-target-key-field-associations>
    <type>oracle.toplink.mappings.OneToOneMapping</type>
    </database-mapping>

    Yes, many thanks for you reply.
    My project has many layer (include DAO + EJB + BO + WEB).
    Toplink objects which are auto created by TopLink has only using in DAO and EJB layer, then toplink objects are transfer to Bean objects (valueObject) which are contain primitive java type as int, long, double... not java wrapper object as Integer, Long, Double... Bean objects are using from EJB to WEB layer. So when set value to bean object from toplink object I sometime don't set all reference toplink object to reference object of bean (although bean has references bean object as toplink object) because there are too big. So when I update data from WEB layer to EJB layer, before update to database, I must get fill all data for foreign key of update object by create new reference toplink object, add reference_id to this object and set it to update object. I waste a lot of time, its very handwork and tire. Are you has any solution about this problem?
    Thank in advanced.
    ThangNQ

  • Create foreign keys to delete child records

    I am unfamiliar with foreign keys, I have 3 tables one is the parent table if a record is deleted in the parent table I would like the record to be deleted from the child record but I think that I am also confused about which should be the parent table
    (purpose is to use in a form)
    parent table (i think)
    AdminEntry table
    entryid ,
    date1,
    date1desc,
    date2,
    date2desc,
    date3,
    date3desc
    In a form each date and its description is placed in the following table
    CalendarEntry table
    calendarid,
    date,
    datedesc
    entryid (fk)?
    so CalendarEntry will have many entries at least 3 from one entryId, this I get but what if I want to delete lets say date2 and date2desc record. If I delete it from AdminEntry table how will calendarEntry table know which one to delete?
    Please help very confused.
    (the other table also inserts to the CalendarEntry table)

    There is a demo of this functionality in Morgan's Library at www.psoug.org under Foreign Keys.
    Look for ON DELETE CASCADE.

  • Advice for Creating a Custom Default User Profile in Windows Enterprise 8/8.1 Preview

    Just after some advice on the Best way to create a custom Default User Profile for our Windows 8 Enterprise Image.
    We are also looking at the Windows 8.1 Enterprise preview so advice on creating a Default User profile for this would also be appreciated.
    My Requirements are listed below
    -Pinned Web sites that open in Windows 8 App style IE
    -Default Windows 8 pre-installed Apps
    -The Microsoft Lync Windows 8 Client from the App Store *I understand this would be tricky, not fussed though if it cant be done*
    -Customised Start screen layout
    I have tried the Copy Profile tag in the Unattend.xml and syspreped the machine, this did not work.
    I have tried using the new "Start Screen Layout" Group Policy object, this also did not work
    The Closest I can get was to setup a user profile, Backup the Default User profile, Rename the User I worked on to "Default", Clean up the temp folder, then navigate through the user registry and replaced any absolute profile paths with the %USERPROFILE%
    variable. This worked in terms of setting the layout of the start screen, but the Lync App was not present, and Windows 8 apps, eg Video, Music and IE, would crash when attempting to open them.
    I know I am doing something wrong, so any advice would be much appreciated.
    Thankyou

    Still not getting the results that I want, to recap I am trying to do the following.
    Create a Windows 8.1 Enterprise Standard Operating Environment (SOE) Image for laptop devices at our school. These devices will be in the Students hands 24/7 and will be joined to our Windows 2012 based domain.
    I am trying to create a custom Default user profile for the image so that when a student logs onto the Laptop for the first time they get a start screen that we have created.
    The start screen consists of Pre-installed Modern Apps, a modern app created by our Software team that is side-loaded, Office 2013 Applications, and most importantly Tiles for Websites such as our Learning Management System and Intranet Portal.
    Now to the issues
    I boot the target system into Audit mode, and setup the start screen accordingly. For the Websites,
    I open the websites in the IE11 Modern app and use the built in control to pin the site to the start screen. Everything goes and looks as expected.
    I then run sysprep with a custom unattend.xml with copyprofile inside it. Again everything runs as expected.
    Now when I create a new user on the system the custom start screen appears however the websites that were pinned are no longer on the start screen. BUT when I manually open the Modern IE11 app, navigate to the website and pin the site, The Tile now appears
    on the start screen in the location I put it.
    <Rant>
    Now this puts us in a situation where we can no longer deliver a Standard Operating environment for not just our managed laptops but also our labs where a student just wants to logon and get to work.
    Why as a Desktop and System Administrator, who manages a fleet of 300+ Desktops and 1000+ Laptops do I not have the full power to customise things they way I want them.
    Yes I am aware of the new Group Policy setting for deploying Start screen configurations, Doesn't work when Web sites are pinned
    Yes I am aware of AppsFolderLayout.bin, Doesn't work for Pinned sites.
    Do the links above to Microsoft TechNet articles explaining how to customise Start Screens help, No they do not.
    Finally I am aware that I can just create a shortcut to the websites and pin those, the issue is that this does not utilise the new Live Tile code that was introduced with IE11 and we plan to use these Tiles as another notification system for our staff and
    students.
    I will continue to work on this, if I manage to find a solution myself I will post the process, however if anyone in the community, or from Microsoft for that matter, has a proven solution to pinning websites to the default user profiles start screen, please
    post it.
    </Rant>
    Thankyou

  • Using FOreign key constraints on tables in database.

    I am student and novice in the field of ORACLE and PL/SQL and Database Creation. I had created a database consisting tables and got problem while applying foreign key constraints.
    CUST_MSTR
    CREATE TABLE "DBA_BANKSYS"."CUST_MSTR"("CUST_NO" VARCHAR2(10),
    "FNAME" VARCHAR2(25), "MNAME" VARCHAR2(25), "LNAME" VARCHAR2(25),
    "DOB_INC" DATE NOT NULL,      "OCCUP" VARCHAR2(25), "PHOTOGRAPH" VARCHAR2(25),
    "SIGNATURE" VARCHAR2(25), "PANCOPY" VARCHAR2(1),      "FORM60" VARCHAR2(1));
    (CUST_NO is PRIMARY KEY, )
    -- EMP_MSTR
    CREATE TABLE "DBA_BANKSYS"."EMP_MSTR"("EMP_NO" VARCHAR2(10),
    "BRANCH_NO" VARCHAR2(10), "FNAME" VARCHAR2(25), "MNAME" VARCHAR2(25),
    "LNAME" VARCHAR2(25), "DEPT" VARCHAR2(30), "DESIG" VARCHAR2(30));
    (EMP_NO is primary key )
    --NOMINEE_MSTR
    CREATE TABLE "DBA_BANKSYS"."NOMINEE_MSTR"("NOMINEE_NO" VARCHAR2(10),
    "ACCT_FD_NO" VARCHAR2(10), "NAME" VARCHAR2(75), "DOB" DATE,
    RELATIONSHIP" VARCHAR2(25));
    (NOMINEE_NO is primary key )
    --ADDR_DTLS
    CREATE TABLE "DBA_BANKSYS"."ADDR_DTLS"("ADDR_NO" NUMBER(6),
    "CODE_NO" VARCHAR2(10),      "ADDR_TYPE" VARCHAR2(1), "ADDR1" VARCHAR2(50),
    "ADDR2" VARCHAR2(50), "CITY" VARCHAR2(25), "STATE" VARCHAR2(25),
    "PINCODE" VARCHAR2(6));
    ( ADDR_NO is primary key )
    Problem: I want to apply foreign key constraints on ADDR_DTLS table so that Before inserting value in ADDR_DTLS table it must check, VALUE in ADDR_DTLS.CODE_NO must be PRESENT either in attribute value CUST_MSTR.CODE_NO or EMP_MSTR.CODE_NO or NOMINEE_MSTR.CODE_NO table .
    I applied the foreign key constraints using this syntax
    CREATE TABLE "DBA_BANKSYS"."ADDR_DTLS"("ADDR_NO" NUMBER(6),
    "CODE_NO" VARCHAR2(10),      "ADDR_TYPE" VARCHAR2(1), "ADDR1" VARCHAR2(50),
    "ADDR2" VARCHAR2(50), "CITY" VARCHAR2(25), "STATE" VARCHAR2(25),
    "PINCODE" VARCHAR2(6),
    constraints fk_add foreign key CODE_NO references CUST_MSTR. CODE_NO,
    constraints fk_add1 foreign key CODE_NO references EMP_MSTR. CODE_NO,
    constraints fk_add2 foreign key CODE_NO references NOMINEE_MSTR.CODE_NO);
    (foreign key)
    ADDR_DTLS.CODE_NO ->CUST_MSTR.CUST_NO
    ADDR_DTLS.CODE_NO ->NOMINEE_MSTR.NOMINEE_NO
    ADDR_DTLS.CODE_NO ->BRANCH_MSTR.BRANCH_NO
    ADDR_DTLS.CODE_NO ->EMP_MSTR.EMP_NO
    When I applied foreign key constraints this way, its gives a error called foreign key constraints violation. (I understand that, its searches the attribute value of ADDR_DTLS.CODE_NO in all the three tables must be present then the value will be inserted. But I want, if the value is in any of the three table then its should insert the value or its gives an error.)
    Please help me out, though i put the question and i want too know how to apply the forign key in this way. and is there any other option if foreign key implementation is not pssible.

    If you are on 11g you can use ON DELETE SET NULL:
    CREATE TABLE addr_dtls
    ( addr_no          NUMBER(6)  CONSTRAINT addr_pk PRIMARY KEY
    , addr_cust_no     CONSTRAINT addr_cust_fk    REFERENCES cust_mstr    ON DELETE SET NULL
    , addr_emp_no      CONSTRAINT addr_emp_fk     REFERENCES emp_mstr     ON DELETE SET NULL
    , addr_nominee_no  CONSTRAINT addr_nominee_fk REFERENCES nominee_mstr ON DELETE SET NULL
    , addr_type        VARCHAR2(1)
    , addr1            VARCHAR2(50)
    , addr2            VARCHAR2(50)
    , city             VARCHAR2(25)
    , state            VARCHAR2(25)
    , pincode          VARCHAR2(6) );In earlier versions you'll need to code some application logic to do something similar when a parent row is deleted, as otherwise the only options are to delete the dependent rows or raise an error.
    btw table names can be up to 30 characters and don't need to end with MSTR or DTLS, so for example CUSTOMERS and ADDRESSES might be more readable than CUST_MSTR and ADDR_DTLS. Also if the Customer/Employee/Nominee PKs are generated from a sequence they should be numeric.
    Edited by: William Robertson on Aug 15, 2010 6:47 PM

Maybe you are looking for

  • Help!{module_catalogue,15999,} Catalogue module is not showing up at all. Thoughts?

    Followed all the steps in Dreamweaver to insert the Catalogue Module and nothing happens. I can see the module code, but when I preview the page nothing. I have added products to the catalogue, and tried adding multiple modules, still nothing. It's g

  • Hover bug with Javascript apps?

    I have an HTML/Javascript AIR app that uses the hover event on certain elements to show/hide them. I've noticed that if the mouse moves out of the *app window* quickly, the app will not register the movement and will continue to show the element rath

  • Error : While Starting the J2EE Server

    Hi All,          When i am trying to open the SAP Console Management i am getting this following error. "sapstartsrv.exe has encountered a problem and needs to close.  We are sorry for the inconvenience." The server which was installed  was also not

  • Which version of OC4J 9.0.2 or 9.0.3 supports jdk 1.4

    does anybody know which version of OC4J 9.0.2 or 9.0.3 supports jdk 1.4?? thanks

  • Storing more than 15 lakhs records in TreeMap

    Hi All, I have a requirement to cache more than 15 lakh records in TreeMap. When i tested it, it takes around one hour for 15 lakh records. Is there any better way to cache this huge volume of records? 15 lakh records may increase in future. So my ap