Can you make a key with delete cascade when there is no primary key?

I have a table with a primary key, and also a field called 'tpid', which is sometimes null, and sometimes has an integer value in it. This integer value corresponds a primary key in another table, and that key is also called tpid.
I would like the following to happen.
If a row in table 1 is deleted, and it has a tpid that is not null, then I want the corresponding row in the second table to be deleted too.
I think a trigger could be written to do this, but it would be better if a foreign key constraint with cascade delete could be used.
One reason that is better is that whenever I script out my database, triggers seem to be left out by default, unless I specifically ask that they not be..
So can this be done - where column in table 1 has some nulls, and is not a primary key, but when its deleted, you want to delete a matching row in a table where it IS a primary key.
Thanks,
Gideon

Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
This is minimal polite behavior on SQL forums. 
>> I have a table with a PRIMARY KEY, <<
That is redundant. Table has a key by definition, but the fact that you said it this way tells us you have a high level of ignorance. 
>> .. and also a field [sic] called “tp_id”, which is sometimes NULL, and sometimes has an integer value in it. <<
Yep! Wrong again! A column is not anything like a field. The only place “field” is use in SQL is for {year, month, day, hour, minute, second} in temporal values. 
>> This integer value corresponds a PRIMARY KEY in another table, and that key is also called tp_id. <<
NO, NO, NO! A key is never NULL by definition. It cannot be NULL in your un-named second table. Where is the DDL? Why do you have manners of a pig? 
I will guess, since we have no clear specs from you, that you want to replace the NULL with a dummy value that can be used with DRI actions. 
Would you like to give us enough information to help you? 
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • HI APPLE, CAN YOU MAKE NEXT IPHONE WITH SAPPHIRE GLASS AND WATERPROOF? WILL BE BEST PHONE ON THE WORLD !!!

    HI APPLE, CAN YOU MAKE NEXT IPHONE WITH SAPPHIRE GLASS AND WATERPROOF? WILL BE BEST PHONE ON THE WORLD !!!

    You're not addressing Apple here. Submit your feedback directly to Apple using the appropriate link on the Feedback page:
    http://www.apple.com/feedback

  • Can you Make A Page With Multiple Videos?

    when i try to add more than 1 video to a page. the 2nd one doesn't show up. is there anyway around this or does each video have to have its own page?
    thanks

    I was doing it on a blank page. When you drop the file on from the media browser you should see a + with a green background. It should load pretty fast unless it is a giant file.
    If you want to add more than one file on a "movie" page, delete the "movie" place holder. Then you can add as many as you like. Kind of defeats the idea of having a movie page!

  • Can you make a cd with iTunes

    I am a retard, and don't know how to work iTunes. Is there any way to make a CD with it?

    Yes, you most certainly can (assuming your computer has a CD burner, of course). You might find the iTunes How-Tos helpful; look under the How Do I..? section for information on burning a CD. Or consult the Help in the iTunes application on your system.
    Regards.

  • Can you make VOIP Calls with an iPod Touch ?

    I know you can surf the web.
    Can you use skype or other browser based phone companies?
    Are you Sure? Why or Why not?

    no you cant, yes im sure because there have been many posts asking the same thing in fact the most recent was a few das ago. And the reply is the same No , and why well ask skype that question. but generally there is no way for 3rd parties to create native apps to run on the ipod touch which will change in February. So wait till then contact skype commenting that you want this support. then leave feedback for apple at the link below cause they dont read these forums
    Also another way of being sure is to google for something like this.. I am sure you have tried that right? Why or why not?
    http://www.apple.com/feedback/ipodtouch.html

  • Can you make a reusable group non-editable when re-used?

    JDev 11.1.1.4.0
    JHS 11.1.1.3.35
    I have a group which, when used as a base group, needs to be editable (create/edit/delete), but when I reuse it as a child group (using a dataCollection parameter) it needs to be read-only. Is that possible to do? Or do I need to create a separate child group to do that.
    I've suppressed all the Save/Cancel/Search stuff, but the New/Edit/Delete buttons are still there.

    OK, I was able to do this by adding a custom parameter and referencing it in the Authorization EL expressions. It's true by default and I pass false when I re-use the group as a detail group.
    Is that the best way? Or am I missing something?

  • I have downloaded a serie and now i want it to put on a dvd . can you make a dvd with menu in idvd from the serie

    i have downloaded a  serie and now i would like to put them on dvd with a menu so each plot can play separatetly

    split the show into parts
    add each episode to your iDVD project ..
    (Just curiosity: Kurt, are you from Stuttgart? )

  • HT5557 Can you make a book with Pages app. to transfer to iBook on the iPad?

    I have a very old manual of Westinghouse Radio schematics (1936-1937).I have scanned the manual in pdf's and wanted to take certain models to put together as one "book" for my own reference. iBook sees each page as a book when I export to it.
    What would be the best way to put them together so iBook sees one book with pages inside?

    I understand.
    I would like to keep the phone as secure as possible from unauthorized use by keeping it locked and disabling siri on the lock screen.
    However I would like my children to be able to use the phone app to call mom.  Seems like this could be accomplished by permitting the owner to imput several numbers that can be called from the locked screen.  Another solution would be to limit Siri's access when the phone is locked.

  • When closing firefox with multiple tabs open, how can you make it keep all the tabs when you reopen firefox

    When i pull firefox back up i want all my tabs to appear in seperate tab windows.

    Go in menu->options->options->select "General" tab and here in "When firefox start" change the option.

  • Can you make a emeded flash video disspear when finished

    IS the a paramater or other setting to make a flash video
    finish when it is finised. Its just a simple screencast video that
    i want to totaly dissapera when completed

    The only way I know to get html into flash is in a in a
    dynamic textfield and what is allowed is very limited. I suppose
    you were thinking of something in flash that looks like a table
    that would be easy enough. Just do it after the end of the video
    and it always helps to use multiple layers if there's any degree of
    complexity.

  • Can you make a line of text appear when hovering cursor over hotspot?

    Hi guys - i'm new so sorry if this has appeared before, i've had a look for the answer but dont know what the function is called so struggled. Basically, what I want to do is have a line of text appear when the cursor hovers over a hotspot. I want the text to be remote from the hotspot - there are 4 hotspots on the page in different locations but I want the relevant text for each hotspot to appear in the same place. Hope that makes sense. Cheers guys

    CSS Disjointed rollovers -
    This demo shows a disjointed text rollover:
    http://alt-web.com/DEMOS/CSS-Disjointed-Text-Rollover.shtml
    This demo shows disjointed image rollovers (images contain captions):
    http://alt-web.com/DEMOS/CSS-Disjointed-Image-Rollover.shtml
    This demos shows a disjointed menu rollover:
    http://alt-web.com/DEMOS/CSS-Disjointed-Menu-Rollover.shtml
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • HT1553 Hi, I'm stuck at step 9. I don't see my external harddrive when I want to save the DMG backup file. Can you please help me with this? I'm desperate to make this backup! Big thanx in advance!

    Hi, I'm stuck at step 9. I don't see my external harddrive when I want to save the DMG backup file. Can you please help me with this? I'm desperate to make this backup! Big thanx in advance!
    http://support.apple.com/kb/HT1553

    Repair permissions and restart your computer.  If this does not work, zap the pram.  You should now see your external hard drive. 

  • Can you make key photos on the iPad?

    Can you make key photos on the iPad?

    Michael Morgan1 wrote:
    That is the only way of doing it.
    When the OP updates to iOS 5, future updates can be performed in Settings > General > Software Update.

  • Where can you make a comment about the new 7.1 software update?  I was dissapointed that the photos of friends that normally pop up when they make a call are no longer appearing.  Just a tiny little circle with their picture in it appears.

    Where can you make a comment about the new 7.1 software update?  I was dissapointed that the photos of friends that normally pop up when they make a call to me are no longer appearing.  Just a tiny little circle with their picture in it appears.

    Here:
    http://www.apple.com/feedback/iphone.html

  • Good day, I can not make video calling with my MAC PRO 15 with FB Mountan Lion operating system   how can I do?    you can you help me? thank you very much

    good day,
    I can not make
    video calling
    with my MAC PRO 15
    with FB
    Mountan Lion operating system
      how can I do?
       you can you help me? thank you very much

    francesco marraffa wrote:
    good day,
    I can not make
    video calling
    with my MAC PRO 15
    with FB
    Mountan Lion operating system
      how can I do?
       you can you help me? thank you very much
    Are you running your MacBook Pro off WiFi or Ethernet?
    Pete

Maybe you are looking for