Trouble adding foriegn keys

I am trying to add a foriegn key to a table through the wizard in the sql server diagram tools. I select the foriegn key table which is film_actors_lookup. The film_actors_lookup table has 2 fields: ActorID and FilmID. Both are primary keys for the film_actors_lookup
table. The Film table has a FilmID primary key. The Actor table has an ActorID as a primry key. When I go to add a foriegn key relationship between the Actors table and the film_actors_lookup table, I get the error that both tables must
have the same number of fields. Why is this not working?

Please post the error message.
Both ActorID and FilmID needs to be PRIMARY KEY in respective tables.
You can see it with below script:
USE [TestDatabase]
GO
CREATE TABLE [dbo].[film_actors_lookup] ([FilmID] INT, [ActorID] INT)
GO
CREATE TABLE [dbo].[actors] ([ActorID] INT PRIMARY KEY)
GO
CREATE TABLE [dbo].[films] ([FilmID] INT PRIMARY KEY)
GO
/* Add Foreign Key - ActorID */
ALTER TABLE [dbo].[film_actors_lookup] ADD CONSTRAINT [FK_Actors_Lookup_Actors_ActorID] FOREIGN KEY ([ActorID]) REFERENCES [dbo].[Actors] ([ActorID])
GO
/* Add Foreign Key - FilmID */
ALTER TABLE [dbo].[film_actors_lookup] ADD CONSTRAINT [FK_Actors_Lookup_Films_FilmID] FOREIGN KEY ([FilmID]) REFERENCES [dbo].[Films] ([FilmID])
GO
- Vishal
SqlAndMe.com

Similar Messages

  • I am having Trouble adding Audiobooks in iTunes 12

    Hello, I am having Trouble adding Audiobooks in iTunes 12.1.2.27 with OSX Yosemite 10.10.3, I downloaded 4 Audiobooks from Audible, Synced my iPod but the new Audiobooks do not show up in either the Audiobooks or Music section of my iPod after I sync my iPod, I do see them in the Audio section of iTunes but not on my iPod, any help would be greatly appreciated. thank you Michael

    I do have an icon of my iPod but if I click on it it disconnects my iPod from iTunes.
    If the iPod is connected via Wi-Fi, please connect with USB. If it's already on USB, or if USB is the same. log out or restart the computer and also restart the iPod, then try again. If it still doesn't work, see below.
    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    The title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    Click the Clear Display icon in the toolbar. Then take the action that isn't working the way you expect. Select any lines that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    Some private information, such as your name or email address, may appear in the log. Anonymize before posting.
    When you post the log extract, you might see an error message on the web page: "You have included content in your post that is not permitted," or "The message contains invalid characters." That's a bug in the forum software. Please post the text on Pastebin, then post a link here to the page you created.

  • Urgent: Error in uploading data in cube after adding new Key figure

    Hi Guys,
    I have added 1 key figure (DEC) to my existing cube. and proceeded as below:
    1. Deleted all data from cube
    2. activated the cube
    3. set Constant 1 for this key figure
    4. activated the transformation
    5. reated a new DTP
    But when i execute it, it gives me error. in updating to infocube ZSDBILL:
    Error while updating to target  ZSDBILL
    Process Terminated.
    all other steps in DTP are succesful like: extraction, error handling and transformation.
    There is no details in long text of these errors.
    Can anyone suggest whats the error stands for or what i am missing.

    Once logout and login back then again activate cube,transformation and run the DTP.
    Hope it helps you

  • Adding new key figures to DP planning area

    I am using APO DP.
    When adding new key figures to a planning area, is there any way of avoiding having to deinitialise and then re initialise the planning area?
    Thanks for any advice on this...

    First of, let us know which version of DP are you using.
    If you are using 7.0, all you need to do is right click on your planning area and select Change Keyfigure setting and you should be able to update the key figures there.
    The below is from SAP help for SAP APO 7.0, you should be able to add the key figure without deinitializing the planning area.
    Key Figure Settings
    Here you can change the properties of the key figures of a planning area, if the planning area has already been initialized. You can also add or delete key figures. However, you can only delete key figures that are no longer used in planning books, data views, macros, or demand forecasts. You can find out in which objects a specific key figure is used with the where-used list.

  • New Zen trouble adding a memory card (not seen)?

    0New Zen trouble adding a memory card (not seen)?8I have a new zen 4gb unit and love it, saw it has a memory card slot so i stuck an 8gb sdhc sandisk 3 extreme memory card in there, figured I could dump more fun stuff in there on it but when i use the zen explorer i don't see that card.
    I formatted the sdhc card in fat 32 and named it sd4zen yet when its in the zen and i check my computer I am not seeing the card in the windows menus to drag stuff over onto for the zen nor is it showing in any of the zen media explorer areas.
    Do i need to dump stuff onto the memory card externally (thru a card reader first) then insert it and access that thru the memory part of the zen menu, or are the zens not able to read from an sdhc sd card or is 8 gb too big (compatability)?
    Thanks for any help on this,
    Bill

    I am a dork, a few mins messing with it i realized in the main menu of the zen with the card inserted hit removable disk and hook up via usb, now my computer sees the sd4zen dri've and i can dump more fun stuff for zen on there...
    Sorry to take up space maybe someone will read this and help them with the same issue i was having or mods if you choose just delete.
    Bill

  • Trouble adding comments using Reader X from enabled comments in Acrobat 9

    I am a Technical Writer with Acrobat 9. Regularly I make my documents comment enabled for reader. IT has been updating systems and some of my recipients now have Reader X. Because of the difficulty they have, when they open the commentable PDF they are having trouble adding comments and wind up printing the document, marking up the hard copy, scanning it and emailing it back. What am I doing wrong? Is Reader X not downward compatible? We want to move forward with technology, not backwards.

    Right click the document opened in Reader X and then click "Select Tool".
    Hope that helps.
    Thanks,
    Abhilasha

  • HT4623 I have updated to ios7 and am having trouble adding appointments to my calendars??

    I am having trouble adding appointments to my various calendars. No probems before ios7 update. What am I doing wrong??

    iPhone 3G IOS 4.2.1 is the latest & greatest. There's no more updates for this iPhone.
    You have to buy a new iPhone since most apps target IOS 6 & IOS 7.

  • Added new key figure in the report

    Experts,
    I have added new key figure in the report .If i display this key figure value in the report it is populating correct value with ERROR(example 22.5 ERROR).The report is on the multiprovider .i have check the value for this in multiprovider it is populating correctly .There is no calculation in the report for this .While extracting in to report i am getting this. Help me to resolve this issue.
    Thanks
    Murali

    Hi,
    I have already created a formula like NODIM(Key field).that only i am using .
    and mapping I did in this way. I went to multiprovider and I have selected this key figure and right click and select (assign) then I have click on create proposal for all infoobjects option.
    Please suggest any thing need to do.
    I am sorry .I did not understand the lonterm solution suggested by you .what is UOM .Please tell me how to map.can you pls tell me clearly please
    Thanks
    Murali

  • Having trouble adding purchased and imported music to my playlists

    I'm having trouble adding purchased and imported music to my play lists. For example when I purchase or import new music to my playlists I have to re sync my ipod or the new songs don't appear on my playlists. Perhaps this is because I once unplugged my ipod w/out first disconnecting it. Previously when I purchased and imported music songs would appear on my play lists when I dragged them from purchased to playlist.

    Remember to authorise your new machine with the Apple ID
    Essentially copy the itunes folder and all sub folders over to the same place in the new computer.
    Windows XP: C:\Documents and Settings\username\My Documents\My Music\iTunes\
    Windows Vista: C:\Users\username\Music\iTunes\
    Windows 7: C:\Users\username\My Music\iTunes\
    Windows 8: C:\Users\username\My Music\iTunes\

  • Trouble adding Audiobooks in iTunes 12.1.2.27 with OSX Yosemite 10.10.3

    Hello, I am having Trouble adding Audiobooks in iTunes 12.1.2.27 with OSX Yosemite 10.10.3, I downloaded 4 Audiobooks from Audible, Synced my iPod but the new Audiobooks do not show up in either the Audiobooks or Music section of my iPod after I sync my iPod, I do see them in the Audio section of iTunes but not on my iPod, any help would be greatly appreciated. thank you Michael

    Hello, I am having Trouble adding Audiobooks in iTunes 12.1.2.27 with OSX Yosemite 10.10.3, I downloaded 4 Audiobooks from Audible, Synced my iPod but the new Audiobooks do not show up in either the Audiobooks or Music section of my iPod after I sync my iPod, I do see them in the Audio section of iTunes but not on my iPod, any help would be greatly appreciated. thank you Michael

  • I am having trouble adding art work for itunes 12.0.1.26

    I am having trouble adding art work for itunes 12.0.1.26. Trying to add artwork after you go into "get info" and then "add artwork" doesn't work. Can anyone help. BTW, went into the authorization edit and gave my user id permission to modify things as was suggested in one posting, but that didn't work either.

    thanks a lot

  • Active Screen Corner Customization with added hot keys fails

    Active Screen Corner Customization with added hot keys fails upon restart. So, if my lower left corner is set to activate the screen saver it works. If I add the command key to that operation it works unit I restart the machine than the hot key requirement vanishes, i.e. the screen saver works but not with the required hot key requirement. The system seems to forget all about the hot key association/requirement after restart. Dumping the file below did not change the situation.
    /Library/Preferences/com.apple.preference.desktopscreeneffect.plist

    You might want to try deleting the screen saver preference/plist - look in your home directory:
    /Library/Preferences/com.apple.preference.desktopscreeneffect.plist

  • Hi guru's what is forign key , and what is foriegn key table

    hi guru's what is forign key , and what is foriegn key table

    hi...
    Foreign key is nothing but simply we can say,
    A field in one table related to field in another table..see the below example...
    consider, there are two tables like emp_personal and emp_official .
    In emp_personal table , the fields are  empid,empname, dob for example. In this table, empid is the primary key field.
    In emp_official table , the fields are empid,dept,designat ion for example. In this also, empid is the Primary key or may not be a Primary key field.
    now we relate these two tables using the foreign key relationship. Foreign key relationship is used to avoid the redundancy mainly...
    now, emp_personal is the Check table( Bcos it holds the empid field, which has the primary key...)
    emp_official table is the Foreign key table (Bcos it holds the empid field, which may or may not be a Primary key).
    now, we foreign key relationship is given. (click the KEY Like  icon in ABAP Dict - Database Table : Emp Official )
    Tables are ready to enter the records...for example create some 5 records in the emp_personal table .
    Table : emp_personal :   Primary Key - empid
    empid     empname    empdob             Status
       1            AAA          1.1.1990          Record saved successfully
       2            BBB          2.2.1990          Record saved successfully
       3            CCC          3.3.1990          Record saved successfully
       4            DDD          4.4.1990          Record saved successfully
       5            EEE          5.5.1990          Record saved successfully
    records are saved in the table : emp_personal.
    now, we are tryiing to create records in emp_official table.
    Table : emp_official :   Primary Key or not a Primary Key - empid
    empid          dept        designation             Status
       1            Dept1        S.E                 Record saved successfully
       2            Dept2       S.SE               Record saved successfully
    now, if u try to create the record which is not in the table emp_personal , which has the empid = 6. but it'll not allow us to create the record 6, bcos of the foreign key relationship between these two tables....
       6            Dept6       P.M                Record doesn't exist......
    now, the foreign key relationship helps us to avoid the duplicate entry......
    Foreign key relationship is possbile between the tables having atleast one same type of field. Also the Technical characteristics of the fields should be same . this is done in the value table.....
    this is the concept of Foreign key...I think this explantion is enough to describe the Foreign key....

  • Prcedure to joining of two tables and pls explore the primary & foriegn key

    Dear All,
    Am new to this forum looking forward to have some discussions and guidance reg ABAP.
    <b>My query is</b>
    what is the prcedure to joining of two tables and pls explore the primary & foriegn key relationships.
    Your kind help is required in this query .
    Thanks n regards
    Carol P

    Hi Carol,
    Joining two tables fetch data from tables that has relevent entry based on the keys. like LIKP and LIPS these are delivery tables. if the business requirement is fetching delivery data that are exists in both two tables. here LIKP will conatins a single entry against a condition and LIPS may contains several entry because one delivery may has multiple line items. so, fetch the data joining the two tables on vbeln that is delivrey number. this is used to increase the performance of the program except for all entries.
    Foreign key is poiting twowards primary key; it may be 1:1 , 1:many and many:many. if field1 of table a is pointing towards field1 of table b. then based on these condition at the time of entry SAP will check how many entry can be entred in field1 of table a.
    regards
    Krishnendu

  • Trouble adding GoodSearch HTML search box: HTML widget doesn't work...

    I'm having trouble adding a GoodSearch search engine box to my site. I've tried the HTML widget thing and also editing the code after it publishes to a folder. Each time, I get a non-functional search box as my end result.
    The GoodSearch tech person says that iWeb might be stripping out or corrupting the Javascript code...interestingly enough, a Google search box works just fine with post code tweaking.
    Any help would be greatly appreciated!
    Here is a link to my test site where the search box (upper right corner) is non-functional: http://web.mac.com/toesproductions/KQ/Home.html
    This is the GoodSearch code:
    <script type="text/javascript">
    function GoGoodSearch_4()
    var charityid = 870537;
    var siteURL = "koreanquarterly.org/home.html";
    var openNewWindow = true;
    var searchtype = document.getElementsByName("goodsearchsearchtype4");
    var baseurl = "http://www.goodsearch.com/Search.aspx";
    var keywordsbox = document.getElementById("goodsearchkeywords4");
    if (typeof keywordsbox != "undefined")
    var keywords = escape(keywordsbox.value);
    var url = baseurl + "?Keywords=" + keywords;
    if (charityid > 0)
    url += "&CharityID=" + charityid;
    if (searchtype[1].checked)
    url += "&Site=" + escape(siteURL);
    url += "&Partner=goodsearch_syn";
    url += "&typetag=" + escape(siteURL);
    if (openNewWindow)
    window.open(url,'SearchResults','height=700,width=900,location=1,status=1,toolba
    r=1,scrollbars=1,resizable=1');
    else
    window.location.href = url;
    function CatchEnter_4(e)
    var key1 = "13";
    var x = "";
    if (document.all)
    var evnt = window.event;
    x = evnt.keyCode;
    else
    x = e.keyCode;
    if (x == key1)
    document.getElementById("goodsearchsubmit4").click();
    return false;
    else
    return true;
    </script>
    <label for="goodsearchkeywords4" style="display:none;">GoodSearch keywords to
    search for</label>
    <input
    type="text"
    name="goodsearchkeywords4"
    id="goodsearchkeywords4"
    onkeydown="return CatchEnter_4(event);"
    style="width:230px;background-image:url('http://www.goodsearch.com/gfx/titleya
    hoo_background.gif');background-repeat:no-repeat;margin-bottom:8px;"
    onclick="this.style.backgroundImage='url(http://www.goodsearch.com/_gfx/spacer.g
    if)';"
    onfocus="this.style.backgroundImage='url(http://www.goodsearch.com/_gfx/spacer.g
    if)';"
    />
    <input
    type="button"
    name="goodsearchsubmit4"
    id="goodsearchsubmit4"
    value="Search"
    onclick="GoGoodSearch_4();"
    style="margin-bottom:8px;font-family:Arial,Helvetica;font-size:11px;"
    />
    <input
    type="radio"
    name="goodsearchsearchtype4"
    value="web"
    /> Web
    <input
    type="radio"
    name="goodsearchsearchtype4"
    value="site"
    /> This Site
    Message was edited by: Andrea Lee

    iWeb does nothing to code you add in the HTML Snippet.
    Actually, iWeb does not care what you put there. It blindly saves the code in a webpage.
    http://web.mac.com/toesproductions/KQ//Homefiles/widget0markup.html
    So, now you have no excuse.
    Just edit the code in the file above until it works.
    After that, copy the code in the BODY of the page and paste in into the HTML Snippet. Otherwise it will overwrite the webpage next time you publish.

Maybe you are looking for

  • Can't hear audio on tracks three and four

    Hi, I'm new to FCP 5. When I go the the audio mix window I can see the audio for tracks 3 and 4, i just can't listen to it. I checked my general settings under real time audio mixing and it says 8 tracks. I don't have any other applications up. Any i

  • Accessing resources in loaded/external SWFs

    I've been looking around for an effective way of solving this issue, but without much like. What I'm trying to accomplish is creating a container for my newest Flash site in main.swf and loading other swf files that provide resources that modify mcs,

  • Edit Naming Bug

    Just tried to edit a file name after editing in PS. God it's painful to do, even after you work out how on earth to do something that is normally so trivially easy. LR imports and displays a file called say "2007-03-15 Betty 004 Provia+Lomo-ed.psd" n

  • SOAP envelope missing some info

    Hello I have been struggling with a web service request for some time and i need some assistance. I have to insert subscriber info into someone elses db.They created a web service for me. My code looks like this: <cfinvoke  webservice="http://41.208.

  • Copy from SEPA formt tree out of DMEE caused wrong format in file

    Hello @ all experts, we used to copy the delivered format tree to use him for payments. But the copy caused the problem <?xml version="1.0" encoding="utf-16" ?> The result is that no file is created. Can you tell me why the copy failed or which setti