Intersection table

Hello,
I have the table customer:
CREATE table customer
cust_id NUMBER(5),
phone_number NUMBER(10) NOT NULL,
first_name VARCHAR(12) NOT NULL,
last_name VARCHAR(30) NOT NULL,
credit NUMBER(5, 2) DEFAULT 0 NOT NULL,
CONSTRAINT cust_pk PRIMARY KEY (cust_id),
CONSTRAINT phone_unique UNIQUE (phone_number)
and the table movie:
CREATE TABLE movie
title VARCHAR(30) PRIMARY KEY,
production_year NUMBER(4),
rating VARCHAR(5) NOT NULL,
max_days NUMBER(1) DEFAULT 1,
quantity NUMBER(2),
CONSTRAINT check_ratings CHECK (rating IN ('G', 'PG', 'PG-13', 'R', 'NC-17')),
CONSTRAINT check_maxDays CHECK (max_days IN (1, 3, 7))
now I want to store the rent of a movie, I come up with the following table:
CREATE TABLE cust_rent_movie
title VARCHAR(30),
cust_id NUMBER(5),
rent_date DATE DEFAULT current_date NOT NULL,
return_date DATE,
CONSTRAINT cust_rent_movie_pk PRIMARY KEY (title, cust_id, rent_date)
Is the table cust_rent_movie an intersection table. Have I to declare the title and cust_id are foreign keys, the primary key consist of an extra attribute the rent_date.
When a customer rent a movie I want to subtract one from the movie.quantity and when the customer return the movie I want to add one to the movie.quantity subtract from customer.credit
Yiannis P.

IPapas wrote:
Is the table cust_rent_movie an intersection table. Yes. It allows for a many to many relationship between customer and movie, though it would seem that you would want to connect customers to a table with 1 row per physical DVD. That table could then be joined to the title movie table in order to get the title.
Have I to declare the title and cust_id are foreign keys, the primary key consist of an extra attribute the rent_date.Title is not a good column to use for the primary key, consider adding title_id. Though unlikely, it is possible that the title wil be updated, ie to correct a typo. Currently you will not be able to update it as there mat be dependent transactions. You will want to add a PK for this table, ie cust_movie_pk.
When a customer rent a movie I want to subtract one from the movie.quantity and when the customer return the movie I want to add one to the movie.quantity subtract from customer.creditIt is usually better to derive values like quantity at run time (or query time) rather than trying to keep a running total of all changes. With appropriate indexes you should be able to quickly calculate that column when required.
CONSTRAINT phone_unique UNIQUE (phone_number)This will cause a problem for you if you have multiple customers in the same household with the same phone number.

Similar Messages

  • How do I Create a Tabular Form for an Intersection Table

    Situation
    There are three tables involved (PROJECT, STAFF, TASK)
    PROJECT(PROJECT_ID, PROJECT_NAME)
    STAFF(STAFF_ID, STAFF_NAME)
    TASK(PROJECT_ID, STAFF_ID, HOURS)
    There is a many to many relationship between PROJECT and STAFF. The intersection table is TASK.
    Issue
    I would like to create a tabular form for the TASK table. I would like to be able to click on a button (Add Row) to add a row to the existing tabular form. The row will have a LOV for the PROJECT_ID (showing PROJECT_NAME) and one for the STAFF_ID (showing STAFF_NAME) and a free form text field for the hours.
    I've tried a bunch of different ways but am unable to acheive this functionality. I must be doing something wrong. This sort of thing is trivial.
    Any guidance/suggestions are greatly appreciated.
    Thanks

    Adding a new surrogate key column to an existing table is not that big a deal.
    alter table t add (pk int primary key);
    create a before-insert row-level trigger to populate the key;Other than that, you are out of luck w.r.t the wizards. Yes, you can define a 2nd PK column in the wizard, but then the 2 PK columns becomes read-only (but you want to update them).
    You can write your own tabular form using htmldb_item APIs and your own after submit processes to process the updates. See the manual Tabular Form Howto in the documentation.
    Thanks

  • Best Way To Update Intersection Tables

    Hi,
    I'm surprised I haven't been able to find anything on this,
    but I was wondering if I could get some advice as to the most
    efficient way to update an intersection table, i.e. a M:N
    resolution table.
    My example...
    Say I have a M:N relationship between tables Cars and Colors.
    To resolve, I form table Cars_Colors with Car_ID and Color_ID as
    PFK's from their respective table.
    So on my form, say we're dealing with record "Ford Ranger,"
    I'll have a bunch of checkboxes with colors, in which multiple
    colors can be selected or de-selected. How should I handle this
    update?
    Currently, I just delete all the existing colors for the
    specific car, and then re-add the list of colors from the form...
    basically a delete then insert on the table... I don't use any
    update sql. But this is a nightmare when trying to keep audit
    history on data changes in the table.
    Any advice? Thanks in advance,
    Mark

    Thanks everyone for your help. Your code samples gave me the
    start to to get this working by using CF code that produced the
    following query in Oracle 8i:
    INSERT INTO Cars_Colors (Car_ID, Color_ID)
    SELECT 2, AA.iNewColorID
    FROM
    SELECT 1 AS iNewColorID FROM dual UNION
    SELECT 2 AS iNewColorID FROM dual UNION
    SELECT 4 AS iNewColorID FROM dual
    ) AA
    WHERE AA.iNewColorID not in (
    select color_id from cars_colors where car_id =2
    )

  • ADF Intersection table / create intersection rows

    Good morning everybody,
    can anyone help me with the task of using a intersection table (Many-to-Many relationship between A and B) with ADF BC ?
    This is my database design:
    TABLE A
    ID (PK)
    TABLE X (intersection table)
    TableA.ID (PK)(FK)
    TableB.ID (PK)(FK)
    Number n (PK)
    TABLE B
    ID (PK)
    I have a new bounded task flow, a dialog (2 pages), which first allows the user to create an A-object.
    The next step is to create B-Objects which belong to the A-Object.
    Then the user can commit or add more new B-objects to the A-Object.
    I have created alle the entity objects and view objects via the assistant of "new business components from tables" which created:
    Entity A
    Entity X
    Entity B
    X Assoc Fk1
    X Assoc Fk2
    VO A
    VO X
    VO B
    VL Fk1
    VL Fk2
    My task flow does this :
    1. create new VO-A (via Create with parameters)
    2. view activity CreateA
    3. create new VO-B (via Create with parameters)
    4. view activity CreateB
    from this activity you can commit transaction or go back to 3. to add more VO-Bs.
    So, how is it possible to handle the intersection table ?
    I read something about "intersection associations and intersection view links" but some people say in this context, that you dont need it (all what is build by the assistant from the tables is ok). Sorry, but this made me very confusing :-/
    Some guys recommended to create one VO which contains alle three entities (A,X,B).
    First thought was, to handle all this business logic (create new VO-X and use setter to the FK/PK IDs...) in the managed bean, but this would be very dirty... There should be a way of doing this automatically...
    I am very new to ADF and would be very happy, if anyone could help me!
    Thanks in advance,
    best regards
    Marcus
    Edited by: moonbird on 20.10.2010 00:46

    Hi John,
    my question is, how can I insert new rows to a intersection table ?
    Is there a declerative way or do I have to write code ?
    As I described before, I have two views as a bounded task flow. In the first view the user creates a new Object-A and in the second view the user creates an Object-B.
    Before each view is started, I create the correspondent VO via CreateInsert declerative, so my views shows the empty row (all its attributes to fill out).
    Thank you very much,
    Marcus

  • Create a BC with intersection table as base table.???

    Hi Axel,
    U have replied that for MVG with M:M create a new BC with the intersection table as the basetable.

    Hi Axel,
    Thank u for ur information its more useful also. Iwant to know one morething .will make u clear about the situation. I need to create an MVG taking Campaign and Offer BCs having M:M link between them. did i need to create an MVG Applet in Offer BC or in Action Employee? Intersection table comes into picture when i need to create a MVG in M:M link without using association applet.
    Regards,
    devu

  • Adding/removing many-to-many associations with intersection tables

    Hello,
    I am using Jdeveloper 11g with ADFBC.
    I have some many to many associations in my application. For example User and Category are associated and there is an intersection entity (UserCategory - Columns are UserId, CategoryId) to save these associations.
    What is the correct method for adding or removing categories assigned to user?
    Thanks.
    Edited by: Deniz Gulmez on 01-Nov-2009 03:25

    I found an example for Jdeveloper 10g, which is discussed [ADF] Adding/deleting entries in a many-to-many relationship
    In that example, many-to-many association is defined as two 1-to-many associations. Actually i've been searching since last week for an example which is made with many-to-many associations but no help. I will change my Model structure if it is not an efficient way to define many-to-many associations with intersection tables.
    I wonder if it is possible to write some methods like :
    addCategoryToUser(String userId, String categoryId)
    removeCategoryToUser(String userId, String categoryId)
    addCategories(String userId, List categoryIds)
    vs.
    Of course i am able to do these by creating a new Row in UserCategoryView (Intersection view), setting it's attributes and saving. Or the opposite, finding the row in intersection table and deleting it.
    For example:
    public void removeCategoryFromUser(String userId, String categoryId){
    ViewObjectImpl vo = this.getUserCategories1();
    vo.setWhereClause("USER_ID = :userId AND CATEGORY_ID = :categoryId");
    vo.defineNamedWhereClauseParam("userId", null, null);
    vo.defineNamedWhereClauseParam("categoryId", null, null);
    vo.setNamedWhereClauseParam("userId", userId);
    vo.setNamedWhereClauseParam("categoryId", categoryId);
    vo.executeQuery();
    Row row = vo.first();
    row.remove();
    I wonder if there is a more efficient way. Any samples would be appreciated.
    Edited by: Deniz Gulmez on 01-Nov-2009 05:49

  • Querying multiple intersection tables against another table for row exists

    Hi all,
    Running on:
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning and OLAP options
    JServer Release 9.2.0.8.0 - Production
    I am setting up email subscription service for news service website. News articles are tagged with multiple audiences, topics, regions and departments. Legacy data model we're dealing with implements one intersection table (M:N) for each of audience, topic, region and department lookup table and main news article table.
    Email subscribers can pick any combination of the above options (audience, dept etc..) to customize the content of their email. Emails will be either daily or weekly digests of articles of interest, based on their chosen options.
    The subscriber options are captured in one table, each option type being its own column. I'm trying to write one query to basically extract all articles that match a given subscriber's chosen options.
    create table audiences(articleid number, audienceid number);
    create table topics(articleid number, topicid number);
    create table regions(articleid number, regionid number);
    create table depts(articleid number, deptid number);
    create table subscriber_options(emailid number,audienceid number,topicid number, regionid number, deptid number);
    insert into audiences(articleid,audienceid)
    SELECT
    ceil(dbms_random.value(1,10)),
    ceil(dbms_random.value(1,50))
    from all_objects where rownum < 100;
    insert into topics(articleid,topicid)
    select
    ceil(dbms_random.value(1,10)),
    ceil(dbms_random.value(1,50))
    from all_objects where rownum < 100;
    insert into regions(articleid,regionid)
    select
    ceil(dbms_random.value(1,10)),
    ceil(dbms_random.value(1,50))
    from all_objects where rownum < 100;
    insert into depts(articleid,deptid)
    select
    ceil(dbms_random.value(1,10)),
    ceil(dbms_random.value(1,50))
    from all_objects where rownum < 100;
    INSERT INTO subscriber_options (
       EMAILID, audienceid, topicid,
       regionid, deptid)
    select
    ceil(dbms_random.value(1,10)),
    ceil(dbms_random.value(1,50)),
    ceil(dbms_random.value(1,50)),
    ceil(dbms_random.value(1,50)),
    ceil(dbms_random.value(1,50))
    from all_objects where rownum < 100;
    commit;If a subscriber hasn't chosen any options, then no rows will exist in the subscriber_options table, which implies that they will receive all articles.
    I am struggling with this query.. can this be achieved using only 1 query or is this a case where some PL/SQL is required?
    All I really want to know is if a given subscriber option matches an option for a given article, using the following boolean logic (topic OR audience) AND dept AND region.
    Because I'm more concerned with row existence, I thought of using the "EXISTS" with subquery approach.
    Thanks for tips and advice.

    Well.. a little persistence, and I think I cracked this nut. ;-)
    WITH instant_subscribers AS
         (SELECT   email_subscriber_id, email_subscriber.subscriber_email,
                   email_subscriber.subscriber_first_name,
                   email_subscriber.subscriber_last_name,
                   email_subscriber.subscriber_identifier_code,
                   email_subscriber.languageid, COUNT (newscreatorid)
                                                                     dept_options,
                   COUNT (newscategoryid) topic_options,
                   COUNT (newscoveragespatialid) region_options,
                   COUNT (newsaudiencetypeid) audience_options
              FROM email_subscriber LEFT OUTER JOIN subscriber_option
                   USING (email_subscriber_id)
             WHERE email_subscriber.subscription_frquncy_type_id = 1
               AND email_subscriber.subscription_status_id = 2
               and email_subscriber_id=53169
          GROUP BY email_subscriber_id,
                   email_subscriber.subscriber_email,
                   email_subscriber.subscriber_first_name,
                   email_subscriber.subscriber_last_name,
                   email_subscriber.subscriber_identifier_code,
                   email_subscriber.languageid)
    SELECT subscr.*, d.*
      FROM instant_subscribers subscr,
           (SELECT ccnews.newsid, ccnews.title, ccnews.embargodate, ccnews.description,
                   ccnews.languageid
              FROM ccnews
             WHERE ccnews.embargodate >= TRUNC (SYSDATE - 7)
               AND ccnews.embargodate < TRUNC (SYSDATE)
               AND ccnews.newsstatusid = 2
               AND ccnews.isreadingroom = 'FALSE'
               )  d
    WHERE subscr.languageid = d.languageid and ( (subscr.audience_options=0 OR subscr.topic_options=0 OR EXISTS (
                        SELECT NULL
                              FROM subscriber_option INNER JOIN ccnews_audience_rel
                                   USING (newsaudiencetypeid, languageid)
                             WHERE subscriber_option.email_subscriber_id =
                                           subscr.email_subscriber_id
                               AND ccnews_audience_rel.newsid = d.newsid))
            OR ( EXISTS (
                     SELECT NULL
                              FROM subscriber_option INNER JOIN ccnews_category_rel
                                   USING (newscategoryid, languageid)
                             WHERE email_subscriber_id =
                                           subscr.email_subscriber_id
                               AND ccnews_category_rel.newsid = d.newsid))
       AND (subscr.dept_options = 0 OR EXISTS (
                    SELECT NULL
                          FROM subscriber_option INNER JOIN ccnews_creator_rel
                               USING (newscreatorid, languageid)
                         WHERE email_subscriber_id =
                                           subscr.email_subscriber_id
                           AND ccnews_creator_rel.newsid = d.newsid))
       AND (subscr.region_options = 0 OR EXISTS (
                        SELECT NULL
                          FROM subscriber_option INNER JOIN ccnews_coverage_spatial_rel
                               USING (newscoveragespatialid, languageid)
                         WHERE email_subscriber_id =
                                           subscr.email_subscriber_id
                           AND ccnews_coverage_spatial_rel.newsid = d.newsid)) order by d.embargodate DESCI basically outer join my subscriber (supertype) with my subscriber_options (subtype)... and count each option type groupe by subscriber, to determine if they have any options for given type (if count is 0, then they chose "all")
    From there, I use this count to "short-circuit" the predicates.. if count=0 OR exists subquery with inner join on chosen options matched to article.
    Explain plan reveals the following:
    Plan
    SELECT STATEMENT  CHOOSECost: 70  Bytes: 727  Cardinality: 1                                                    
         36 SORT ORDER BY  Cost: 70  Bytes: 727  Cardinality: 1                                               
              35 FILTER                                          
                   10 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS Cost: 64  Bytes: 371  Cardinality: 1                                     
                        9 NESTED LOOPS  Cost: 68  Bytes: 727  Cardinality: 1                                
                             7 VIEW NEWSROOM_DEV02. Cost: 4  Bytes: 356  Cardinality: 1                           
                                  6 SORT GROUP BY  Cost: 4  Bytes: 121  Cardinality: 1                      
                                       5 FILTER                 
                                            4 NESTED LOOPS OUTER  Cost: 2  Bytes: 605  Cardinality: 5            
                                                 2 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.EMAIL_SUBSCRIBER Cost: 1  Bytes: 80  Cardinality: 1       
                                                      1 INDEX UNIQUE SCAN UNIQUE NEWSROOM_DEV02.EMLSUBSR_PK Cardinality: 1 
                                                 3 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 1  Bytes: 205  Cardinality: 5       
                             8 INDEX RANGE SCAN NON-UNIQUE NEWSROOM.CCNEWS_IN Cost: 1  Cardinality: 317                           
                   16 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_AUDIENCE_REL Cost: 5  Bytes: 12  Cardinality: 1                                     
                        15 NESTED LOOPS  Cost: 5  Bytes: 39  Cardinality: 1                                
                             12 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                                  11 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                             14 BITMAP CONVERSION TO ROWIDS                           
                                  13 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_AUDIENCE_REL_IN                     
                   22 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_CATEGORY_REL Cost: 5  Bytes: 12  Cardinality: 1                                     
                        21 NESTED LOOPS  Cost: 5  Bytes: 78  Cardinality: 2                                
                             18 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                                  17 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                             20 BITMAP CONVERSION TO ROWIDS                           
                                  19 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_CATEGORY_REL_IN                     
                   28 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_CREATOR_REL Cost: 5  Bytes: 14  Cardinality: 1                                     
                        27 NESTED LOOPS  Cost: 5  Bytes: 41  Cardinality: 1                                
                             24 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                                  23 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                             26 BITMAP CONVERSION TO ROWIDS                           
                                  25 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_CREATOR_REL_IN                     
                   34 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_COVERAGE_SPATIAL_REL Cost: 5  Bytes: 12  Cardinality: 1                                     
                        33 NESTED LOOPS  Cost: 5  Bytes: 39  Cardinality: 1                                
                             30 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                                  29 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                             32 BITMAP CONVERSION TO ROWIDS                           
                                  31 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_SPATIAL_REL_IN                     To me it looks pretty good... I'd be curious to know how it looks to a trained eye.. ;-)
    I do get my results back as expected...
    Edited by: pl_sequel on Sep 24, 2010 4:24 PM

  • Creating an intersection table record

    I want to add an intersection table record and the related FK record at the same time. I have three tables with cardinality shown below:
    Restaurants 1:N RestaurantRatings 0..1:1 Ratings
    Thus, a restaurant can have zero or more customer ratings (i.e. restaurant reviews).
    We use an intersection table (i.e. "RestaurantRatings") because table "Ratings" is also used for rating food items, which involves another intersection table (not mentioned above) to keep track of the food
    ratings.
    I followed the instruction in the ADF Developers Guide 11g Release 1 (11.1.1) for the following sections:
    38.8 Controlling Entity Posting Order to Avoid Constraint Violations
    39.9 Creating a View Object with Multiple Updatable Entities
    Per section 38.8, I created the following override of EO method RestaurantRatingsImpl::postChanges for intersection table RestaurantRatings.
    public void postChanges(TransactionEvent e) {
    //If current entity is new or modified
    if (getPostState() == STATUS_NEW ||
    getPostState() == STATUS_MODIFIED)
    //Get the associated restaurant for this intersection-table row
    EntityImpl restaurants = this.getRestaurants();
    //If there is an associated restaurant
    if (restaurants != null)
    //And if it's post-status is NEW
    if (restaurants.getPostState() == STATUS_NEW)
    * Post the restaurant first, before posting this
    * entity by calling super below
    restaurants.postChanges(e);
    EntityImpl rating = this.getRatings();
    //If there is an associated rating
    if (rating != null)
    //And if it's post-status is NEW
    if (rating.getPostState() == STATUS_NEW)
    * Post the rating first, before posting this
    * entity by calling super below
    rating.postChanges(e);
    super.postChanges(e);
    Then I use RestaurantRatingsViewLink, in the "Oracle Business Component Browser", to create a new Ratings record that is linked to an existing Restaurants record. My debugging session reveals that line
    "this.getRatings();" returns null when I create a new Ratings record.
    Any ideas, or better examples for how to properly create an intersection table record or update a view object with multiple entities objects.
    Thanks,
    Travis

    Setting Composition on RestaurantRatingsRatingFk1Assoc didn't fix the problem. This association defines "Ratings.id" as the source and "RestaurantRatings.RatingId" as the destination.
    Using the Oracle Business Component Browser, I attempted to insert a new row in the ResataurantRatings intersection table. I get the following error:
    (oracle.jbo.AttrValException) JBO-27014: Attribute RatingId in AppModule.RestaurantRaitingsView1 is required.
    I suspect we can't use composition because we have two associations from intersection table "RestaurantRatings". That is, table "RestaurantRatings" has two foreign keys. One to table "Restaurants". The other to table "Ratings".
    Our RestaurantRatingsView has "Restaurant" as the master EO and "Ratings" as the detail EO. They are both set as "Updatable" in the view's "Entity Objects" tab.
    Is composition really usable in this situation? Is there a similar example?
    Travis

  • Looking for a recursive answer using a intersection table. Possible CTE? Other method?

    Hello all,
    This is my first time on the forums, so please bear with me.  Im also a somewhat novice SQL coder but I have a question that I feel might be best answered my the more advanced folks on this forum.
    I have 3 tables, a user table, a group table and a membership table.
    Say:
    user_table
    +-------------------+
    | user_PK |
    | Id |
    | Name |
    | Description |
    +-------------------+
    Group_table
    +-------------------+
    | group_PK |
    | Id |
    | Name |
    | Description |
    +-------------------+
    Group_members
    +----------------------+
    | group_members_PK |
    | Group_ID |
    | Member_ID |
    | Member_type |
    +----------------------+
    The group_ID is linked to the Group_table.ID and the Member_ID can be either linked back to the group_table or user_table depending on the value of member_type.  
    It is possible to have nested groups, and each level of nesting can have users as well not just nested groups.  Sort of how the windows group nesting model works.
    I would like to end up with being able to have output that lists only users, their descriptions and their nested group path if any.
    If you need more clarification please let me know.   I know this maybe a simple thing, but Im unsure how to do it.  Thanks in advance.

    >> This is my first time on the forums, so please bear with me.  I am also a somewhat novice SQL coder but I have a question that I feel might be best answered my the more advanced folks on this forum. <<
    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. There is no generic “id”, “name, etc. in RDBMS. Tables have to have a key,
    but we do not put “_pk” on the name. Read a copy of https://www.simple-talk.com/books/sql-books/119-sql-code-smells/ so you will stop tibbling and other bad practices.  
    You should follow ISO-8601 rules for displaying temporal data. We need to know the data types, keys and constraints on the table. 
    Avoid dialect in favor of ANSI/ISO Standard SQL. And do not draw ASCII pictures! They do not compile. 
    >>The group_id is linked [sic] to the group_table.id [sic] And the member_id can be either linked [sic] back to the group_table or user_table depending on the value of member_type.  <<
    RDBMS has no links; that was in network databases in the 1970's. No wonder you want to use recursive CTEs; they are cursors 
    >> It is possible to have nested groups, and each level of nesting can have users as well not just nested groups.  Sort Of how the windows group nesting model works. <<
    Then you should use a nested sets model.  Since you did not post sample data, DDL  or correct specs, Google it.
    --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

  • UIX: How to add linked view table columns to the Read-only table

    Hi
    I have two tables
    T1: ID, STAFF_ID, NOTE
    T2: STAFF_ID, USERNAME
    I have created corresponding entity objects (E1, E2), views (V1, V2), association A(E1->E2 as *..1 using STAFF_ID) and viewlink VL(V1->V2 as *..1 using association A).
    My model in AppModule looks like
    V1
    ----V2 via VL
    Now I have single UIX page in which I drop V1 as Read-only table. The table displays columns correctly: ID, STAFF_ID, NOTE
    What I want is to add a column STAFF_ID from the V2 into this table. I have tried to drop it into the table but when the page is run it does not display anything in that column. It has to do something with binding.
    I have done similar test with dropping V1 as read-only FORM and then added STAFF_ID from V2 as messageTextInput and everything is rendered correctly.
    Anyone knows how to do the same thing but with table?

    Yes that is true but I would like to give another example where this may not apply.
    Say I have 3 tables
    CLIENT(INDIVIDUAL_ID,...)
    ADDRESS(ADDRESS_ID,...)
    ADDRESS_HISTORY(ADDRESS_ID, INDIVIDUAL_ID,BEST_ADDRESS)
    where ADDRESS_HISTORY is intersection table in CLIENT to ADDRESS many to many relationship.
    Suppose I have VO2 that consists of ADDRESS and ADDRESS_HISTORY entities (corresponding association exists) and user needs to add new address for the selected customer in VO1 (made from CLIENT entity). There are several issues here:
    1) An input form made out of VO2 must contain an entry for BEST_ADDRESS flag but since it will be read-only, seems that this approach may not work. However, I found a post re:Updating view objects with multiple entities that provides workaround this.
    2) In that case assume that I use DBSequence to automatically add ADDRESS_ID when user inputs new record in this input form. I am using DB Trigger on ADDRESS table and have selected ADDRESS_ID in ADDRESS entity as DBSequence. Now observe that VO2 would contain another ADDRESS_ID from ADDRESS_HISTORY entity which has to be automatically populated with the same value. How?
    In a nutshell my question relates to the problem how to automatically populate intersection table when new record is added to the detail. But the trick is that some attributes of the intersection table must be inserted by the user in the form..
    Please advise

  • Parent child table question

    HI i have some questions which iam unclear please help me
    1) in a parent child relationship.. is it always 1-m relation from parent to child?
    2) can a parent table be on many side? i.e can a child - parent be 1- m?
    3) if i itake employee as child table and department as parent table then dept_id will be the foreigh key in employee table ...
    Now if i want to add a new employee who is not assigned to any department can i add it ?
    4) In an identifying relationship ... a child table has concatenated primary key (pk of child,pk of parent)
    should we still add any other primary key to the table....in addition to this concatenated key?
    thanks in advance
    raj

    Hi!
    1) in a parent child relationship.. is it always 1-m relation from parent to child?
    yes unless you create a unique index on the foreign key column
    2) can a parent table be on many side? i.e can a child - parent be 1- m?
    no, if you need an n-m you will need an intersection table
    e.g. employees - emp_dept - departments
    in this case the emp_dept table would contain the foreign keys of employees and departments
    3) if i itake employee as child table and department as parent table then dept_id will be the foreigh key in employee table ...
    Now if i want to add a new employee who is not assigned to any department can i add it ?
    no, you will have to insert the master first
    Best regards,
    PP

  • Can Shuttles be based non-base  table ViewObjects with transient attributes

    Hello,
    Users have to select records from a data collection and a Shuttle looks most appropriate/nice for this purpose. We can introduce technical intersection tables in order to generate the Shuttles with JHeadstart 10g R3 if necessary, but there is no “functional” need to update any data in the database and therefore it would be practical if the ‘right’ side from a Shuttle can be based non-base table ViewObjects with transient attributes only. So, our interested is to know which records have been selected, i.e. moved to the right side from the Shuttle.
    Hope that my question is clear enough.
    Greetings,
    Michael

    Michael,
    This cannot be generated out-of-the-box.
    It is easiest to add the shuttle post-generation to your page, and then create a custom template to generate your custom shuttle into the page. I suggest you take a look at an example of a generated shuttle in a page, and the JHeadstart IntersectionShuttleBean class. You will see that the value property of <af:selectManyShuttle> points to the selectedKeys method in the JHeadstart Shuttle bean. In your case, you can create your own managed bean and bind the value property to your own method which will provide you access to the selected rows. The value property of the selectItem within the af:selectManyShuttle determines the property that is used to identify the selected row (which is the row key in case of Jhs-generated shuttles).
    Steven Davelaar,
    JHeadstart Team.

  • M:N Relation and plural name for associative Table

    Hi,
    I'm using DM 3.1.4
    In my logical model, 2 entities and an M:N relation. I define a name for this relation
    Entity Student
    Entity Stage
    Relation Registration
    I create a glossary with plural form for these three names (entities name and relation name) :
    Student --> STUDENTS
    Stage --> STAGES
    Registration --> REGISTRATIONS
    When I generate relationnal model with "apply name translation" option, my two tables are named correctly with the plural name, but the associative table is named with the relation name (registration), not with the plural form (REGISTRATIONS)
    Is this a bug ? Is there another way to automatically define plural name for an associative table ?
    Thanks
    Fabrice.
    Edited by: FabriceC on 22 mars 2013 14:03

    Hi Fabrice,
    thanks for reporting the problem. I logged a bug for that.
    There is no another way for setting a plural name for intersection table. If you switch to 3.3 then you can set the name manually and lock it so it cannot be changed further.
    Philip

  • JOIN for many-to-many linked tables?

    I have two tables, A and C, linked by a many-to-many intersection table B.
    I'd like to do a select from A with a LEFT OUTER JOIN to C for items mapped via B. A row in A may or may not have rows in C linked to it.
    I've tried to do a select using sub-selects but then I don't get the rows from A that don't have related rows in C.
    When I try to use the syntax of a LEFT OUTER JOIN I can't figure out how to link A and C via the B table.
    I would appreciate suggestions for how to approach this.
    Thanks in advance,
    George

    EXAMPLE
    SQL> L
      1  with A as (
      2  select 1 col1, 1 col2 from dual union all
      3  select 2     , 1     from dual union all
      4  select 3     , 2     from dual)
      5  ,
      6  B as (
      7  select 1 col2, 1 col3 from dual union all
      8  select 2     , 3     from dual)
      9  ,
    10  C as  (
    11  select 1 col3 from dual union all
    12  select 2      from dual union all
    13  select 3      from dual
    14  )
    15  select *
    16  from      A
    17  LEFT JOIN B ON (A.COL2=B.COL2)
    18* LEFT JOIN C ON (B.COL3=C.COL3)
    SQL> /
          COL1       COL2       COL2       COL3       COL3
             1          1          1          1          1
             2          1          1          1          1
             3          2          2          3          3

  • Many-to-many association: inserting in the detail table fails

    I'm using jdeveloper 11g and configured the many-to-many association as described in the documentation, so I have accessors in both directions, with composition association and a many-to-many link view. Using the business component browser, the link view works for viewing the data in both directions, as one would expect, however inserting in the detail table fails as follows: the key of the master table is the new value of the detail table's key column instead of the intersection table's foreign key column. Is this a known problem, or is there something I have done wrong?

    If your m-m join table has additional fields there best solution is normally to define a class for the join table.
    i.e.
    beforeProgram
    -m-m-> Assumption
    Assumption
    -m-m-> Program (optional/read-only)
    -> after
    Program
    -1-m-> ProgramAssumptionAssociation (private-owned)
    ProgramAssumptionAssociation
    -1-1-> Program (pk)
    -1-1-> Assumption (pk)
    - createByUser
    - etc.
    Program
    -1-m-> ProgramAssumptionAssociation (independent/optional)
    You could also enable batch-reading or joining on the 1-1 relationship to read the target objects efficiently.

Maybe you are looking for

  • Button in outlook email from WF

    Hi All, I am sending a email from WF to Outlook with the hyperlink for SBWP (SAP Inbox). When i click on hyperlink it does open SBWP in HTML version but the workitems are not showing any buttons in there. But when i open the same workitem in SAP SBWP

  • Add UDF to OPOR ,OINV ... via DI API

    Hello... i want to add a User Defined Field to Documents via DI API. Is this possible? And if its possible, please show me a way to do it thx best regards Matthias

  • Multiple layer of group by

    hello all: I learned how to use coherence Aggregator functions, this is an example: GroupAggregator aggregator = GroupAggregator.createInstance(prop, new BigDecimalAverage(target)); Map<Object, Object> ret = aggregate(filter, aggregator);it works fin

  • Pls explain terms certificate and notification

    hello All , can you please let me know the relation between Certificate and notification  (how to creat both ) and  when this willl be comes during inspection , whats the function of both ..i am little confuse ,please help ... regards Prerna Varma

  • Top margin when printing with Generic text driver

    I created a report in Character Mode and tryed to print it using the Generic Text windows printer driver, but the Reports is adding a non-specified top margin. I already removed all the margins of this report in the Layout Editor but the problem cont