Question: Is foreign key references to a different column in the same table

Hello

I'm not grasp this concept. Would you be able to provide the logic how and why you need to create a foreign key that references a column of the same table?

For example, referencing the schema, SupervisorNo @ here is a FOREIGN KEY to the "EmpNo" column in the same table.

EMPLOYEE (EmpNo, title, Fname, Lname, phone, Email, date of birth, sex, salary, HireDate, OutNo, SupervisorNo @)


Why would you want to do this and how can it be used? If you are filling out the data in the table, and this constraint is enabled, you will not be able to load whatever it is because the "EmpNo" column will be empty.


Any input you can provide me with this would be greatly appreciated. Thank you!



His name

Self-referential integrity constraints

Lets say that we have the table emp with emp_no and mgr_no columns.

Now all managers should also be an employee too. How can I check this when inserting data into this table? I applied auto integrity constraint. It would help me to make sure no handler (doesn't mean no mgr_no) must be registered if this Manager is not an employee of this organization. Which means, I won't be able to enter any mgr_no in the column until and unless that the same employee also is an employee (emp_no from the same table).

Check the link as well below.

Data integrity

Thank you

Ishan

Tags: Database

Similar Questions

  • place a select query calculation in a different column in the same table

    How can I put my calculation result in a column named within the same table?

    I have a table called: dgpercentagedatachart

    I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage

    In the query, I gave the result the Alias of the cal

    What I want is to put this result in my application or my calculation (in percentage) in my column "percent" on my table of dgpercentagedatachart vacuum.

    How can I configure this syntax?

    This is the select query, I came with:

    Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.

    100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal

    of dgpercentagedatachart;

    Here are the results:

    CAL lowestfeederrating Totalcecrating

    8,978 7.48166666666666666666666666666666666667 120

    30.951 25.7925 120

    5.04                         120                          4.2

    Hello

    2685870 wrote:

    How can I put my calculation result in a column named within the same table?

    I have a table called: dgpercentagedatachart

    I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage

    In the query, I gave the result the Alias of the cal

    What I want is to put this result in my application or my calculation (in percentage) in my empty column '%' on my table of dgpercentagedatachart .

    How can I configure this syntax?

    This is the select query, I came with:

    Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.

    100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal

    of dgpercentagedatachart;

    Here are the results:

    CAL lowestfeederrating Totalcecrating

    8,978 7.48166666666666666666666666666666666667 120

    30.951 25.7925 120

    5.04                         120                          4.2

    To change an existing column in a table, you can use the UPDATE or MERGE, instructions like this:

    UPDATE dgpercentagedatachart

    Percentage of VALUE = 100,00 * totalcecrating

    / lowestfeederrating

    ;

    Noramlly, tables is not redundant columns like this.  If percent can always be calculated from other columns, then it is probably better to calculate at run time and store it in the database, where you will have to be updated each time the columns it depends on change.  You can use a view to avoid having to encode them the calculation.

    If you really don't want a column that can be calculated in the same lines other columns, then use a virtual column (if you use Oracle 11 or higher).

    I hope that answers your question.

    If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.

    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • With the help of table 'helper' to fill the 2 different columns in the same table

    I have a table that contains two columns that use abbreviations that I want to join to another table "assistance" that develops on what mean these abbreviations. I have my query to display the full name of these abbreviations, rather than the abbreviated name.

    For example,.

    Table 1

    Name acronym
    ====== ======
    MY Monday
    KILL Tuesday
    WEDNESDAY Wednesday


    Table 2

    Entry day due date
    ====== ======
    LUN MAR
    MAR SEA
    SEA OF LUN


    I want to create a query that will show you:

    Entry day due date
    ====== ======
    Monday Tuesday
    Tuesday, Wednesday
    Wednesday Monday

    I can get it to map a column, but not both. Any help?

    Assuming that you really do need the table of the acronym (i.e. Oracle includes functions to translate date abbreviations).

    SELECT a.full_name entry_date,
           b.full_name due_date
      FROM table1 a,
           table1 b,
           table2 c
     WHERE a.acronym = c.entry_day
       AND b.acronym = c.entry_day
    

    Justin

  • How to take a column of duplicate names and fill a different column with the same names, excluding duplicates?

    How to take a column of duplicate names and fill a different column with the same names, excluding duplicates?

    I find easier to use this copy separate Automator Service (download Dropbox).

    To install in your numbers > Services, double-click menu just the package downloaded .workflow and if necessary give permissions in system preferences > security & privacy.

    To use, just:

    1. Select the cells in the column with duplicate names.
    2. Choose separate copy in numbers > Services menu.
    3. Click once in the upper cell where you want the deduplicated values appear.
    4. Command-v to paste.

    SG

  • Is it possible to put different movieclips in the same table?

    Hello. I have two different balls movieclips. I want to put the two in the table with a single bullet, but it seems that all the second movieclip instances are not controlled by bullet_ary [i]

    Yes, you can add more than one:

    var mcA:Arrray = [];

    for (var i: int = 0; i<>
    mcA.push (new MovieClip());

    }

  • Different guests on the same column

    Gurus:

    I have a requirement where we need to have Date guests separated for 4 different promotions.
    Now, I was thinking about the presentation configuration variable, but then it does not work with 'Between' condition.

    So how can I compare a fact for 4 different promotions (Sun) with 4 dates different (Sun) in the same report?

    I don't know if this is possible.
    Please help me.
    Thank you.

    Vinay

    I'm not sure that I understand your question completely, but it seems you need to get the same value (say sale) measure for 4 different dates in the same table.

    My suggestions would be to create dims again and use union all with each union report report led at different times of Sun.

  • Using different filters on the same measure in single result table (view)

    I have a table of twelve columns, each column with different filters tailor-made same table actually. Say a filter column (several people existing on 01/01/2003) comes from people dimension (date_of_birth < = January 1, 2003 ""). Two filter in column b (number of people living in Bucharest between 1 January 2004 and 1 January 2006 "") is (between 2004 and 2006 date_of_birth) etc.
    How do I use column a & column b in the same table of results (view)? I need the different filters on the same table.

    Thank you!

    Published by: seiciu on March 27, 2010 08:51

    Hello
    This filter clause works.
    filter (using Date = current_date)
    filter (using Date = date'2010-01-01')
    filter (measures using the year between 2004 and 2006)
    Concerning

  • Question on foreign key

    Hello

    I have a question about foreign key. When we create an index on a foreign key index name are displayed in the column index_name dba_constraints DD.

    But the name of the index associated with the primary key is displayed.

    Why so much?

    Thanks in advance.

    Unique or Primary Key cannot guarantee the uniqueness of a column with an Index on that column. That's why Oracle will create an Index by default if there is no such thing as an index on that column all to utter those two constraints. If an index is always associated with these two constraints.

    But no foreign key guarantees uniqueness on a column. And an Index on a foreign key is not required. So even if you create an index on a foreign key column that index is not associated with the foreign key.

  • Key Reg primary and foreign at the same table

    Hello

    It is - ok if create primary and foreign keys on the same table itself?

    For example:

    In a table X, I have two columns such as Codeunite and ParentUnitcode.
    Is it ok if create Mt10 as principal and ParentUnitcode as foreign keys in the table itself?

    The foreign key base table: OrganizationalUnit
    Foreign key columns: ParentUnitCode
    Primary/Unique key base: OrganizationalUnit
    Primary/unique key col: Mt10

    Can anyone answer me on that?

    Concerning
    Rajesh

    OWB,

    If the two tables are favouring a one-to-one relationship so there no need to have two separate tables and so you can have free referential foreign keys in the same table where the primary key.

  • Combine data sources with different granularity in the same fact table?

    I have two operating tables 'Incident (157 columns)' and 'unit (70 Colums) '. For all the "incidents" happening there could be one or more records in the table of the 'unit '.

    As part of my design of data mart, I have merged the tables in one "makes the incident (227 columns)" and insert records from two tables with a join condition between them [incident. IN_NUM = Unit.IN_NUM].

    Is this correct, is my question? or am I mix data sources with different granularity in the same fact table. Appreciate your help.

    Best regards
    Bees

    Bees,
    Are the measures of the 'Incident', repeated during an incident given, in more than one record in the table of the unit? If so, then the sum (indicent.measure) will give an incorrect result?

    What is there to merge physically tables set outside OBIEE? With OBIEE you might have a table of 'facts' logic to present the user with report, which from tables separated units and Incidents and would stop the occurrence of incorrect aggregations. A common piece of modeling in the same way would be arrested in OBIEE headers and lines of command, quite common to have a logical fact 'orders' which contained the two header orders and order line, this translates into the Incidents-> relationship of units.

    To do what I mentioned, is relatively simple, you need a "Dim - Incident" at two levels, unit, mapp and Incident unique identifiers as keys to level and then use these levels to define the content of the levels correctly in your 2 tables logic sources logic "done", IE the LTS Incidents at incident level LTS units as level of units.

    Hope this helps, let us know if you get stuck.
    See you soon
    Alastair

  • I have 2 different accounts on the same sites. Whenever I go on this site, one of my usernames prefills the field of the United Nations, and I can't access the other account. I can't replace my pre-filled username. Ideas?

    I have 2 different accounts on the same sites. Whenever I go on this site, one of my two (always the same) identifiers pre fills in the username field and I can't access the other account. The Web site legitimately refuse my password. I can't replace my username pre-populated because the second I hit enter to open a session, the initial username is rewritten in its field. Or user names is registered by firefox anywhere in the "Tools"; Options, security, advanced, or fields from the privacy menu.

    I noticed that this Web site has installed a cookie on my computer called "_rememberme" that contains the user name plaguing me.

    This is a Web site that I have access to very sensitive and important information, and I have to have two accounts available at different times.

    Thanks, Joshua
    XP, sp3; FF3.6.3

    This has happened

    A few times a week

    == I added the second account on this Web site.

    You will need to disable that remember me cookie, and make sure that you remove a tick to remember you on this Web site.
    Tools > Options > privacy > Cookies: "show the Cookies".

    You can disable the automatic filling of a name and a password.

    See:
    http://KB.mozillazine.org/Password_only_filled_after_entering_user_name
    http://KB.mozillazine.org/signon.autofillForms

    To open the topic: config page, type Subject: config in the address bar (address) and press the Enter key, as you type the url of a Web site to open a Web site.
    If you see a warning then you can confirm that you want to access this page.

  • Please help me to orgnize different version of the same application

    Hi all

    It is so messy for me to create a different version of the same application to different platform, to touch, to not touch.

    Can someone help me understand how to manage the same code base for all versions. In addition, we manage all the new functionality of the platform. These things also create headaches by signing the application. With JDE plug-in in eclipse, we are not able to understand, how we will do it.

    Please help me.

    Thank you.

    Adarsh Pandey

    Hi Alaka

    You can make use of the Macro.

    Suppose you want to have the same code base for touch and non-touch devices. You can define a macro saying IS_TOUCH. now in the code, you can put a brake, if this option is enabled, then include the key code that include no button code.

    We had done the same for "BOLD" devices and the storm.

    You can give it a try, in the same way, you can have separate devices also Macro.

    Thank you

    Ankit

  • Lightroom can open 2 different photos at the same time display side by side?

    or if not, is there another program that can do this?

    What is behind this survey is the fact that I have to directly view and compare the 2 pictures of the bird even close together in the same time and location (in a level of detail) to determine that it was certainly better.

    Authorization of repairs to my most recent goal that is at stake here that I must first demonstrate the mfgr that lens is below standards and needs attention.

    I want to compare a picture of the bird in question with the above goal and one I know to be reliable strong.

    Please help in this mission.

    Thank you.

    HI Nikon D90 gent II,.

    YES - Lightroom TO compare 2 different photos at the same time. It also allows you to zoom in to areas and match zoom.

    In the LIBRARY module, make sure that your toolbar is open under the grate.

    You can press "T" on the keyboard to make it visible.

    Select both images and click on the area of comparison of X Y. My arrow in red below.

    The two images appears then side by side with a labeled as the "Select" and the other marked 'candidate '.

    You can click and drag the Zoom slider that appears now on the toolbar to zoom for both images.

    To align the images, you can click the lock in the toolbar to unlock

    Click on and drag on the image to align with the other, then click on the padlock to lock in place.

    Then you can zoom in easily all over the two images by using the Zoom slider at the same time for comparison.

    In fact, you can click the button of "Carousel", the one with the three grey squares to the right of the X Y button on the toolbar and to compare the images of 3 or more.

    TO remove an image, simply click on the X in the corner of the image, and it will be removed at the carousel compared so you can then get more unless you images.

  • PS shows two different colors under the same

    I have the 61BEBF and the 28BEBF in color Adobe and I try to import them to PS and they look on the screen of the same color. It is not a monitor problem, because Adobe color, I can see the difference between the two colors. What can I do?

    You must realize that the hexadecimal notation is meaningless without reference to a specific color space.

    Hex is not different from RGB - the same number will produce a different color in different color spaces. And conversely, the same color will be different hexadecimal numbers in different color spaces.

    Hex was invented before the modern color management and the concept of the color spaces. The only color space, you had back has your monitor, which is of course different from the configuration to the configuration. Then hex has been designed as a convenient method to designate the monitor values. There was never any pretext of accurate color fidelity.

    Today, we have something much better and hex is really outdated and obsolete.

    I suspect that the reason why it has survived for so long, that is that it sounds very "computerish" and geek, and so people incorrectly assume that it has a special meaning. This isn't.

    Get used to working with the RGB values in the color spaces defined and specific. For the web, this would normally be sRGB.

  • The different poses in the same psd file store

    Hi, I imported a character of fuse for Photoshop - now my question is: how to back up different poses for the same character?

    I watched layers, but it seems that this would require duplicating all active 3D - which means that I would not be able to update the character and then export it in different poses, I have set myself.

    After trying, it seems not possible to update a fuse character and these changes appear in Photoshop. I get another file with the same name in the library. Apparently the fuse does not recognize when there are two files with the same name and it seems not to be a dynamic link between the fuse and Photoshop. Perhaps there is a function in Ps similar to the function of sequences to replace or recharge in After Effects, but I don't the have not found.

Maybe you are looking for