Database design with some tables with EAV format

We are designing a database in which most tables follow a straight relational design.  Some tables, however, would benefit from an entity-attribute-value structure.
Specifically, we want to be able to add new value categories simply by adding a row in a data dictionary table.  At a later point, we want to create cursors where those categories show up as columns.
Can someone point to tools or generic code that does that job?
Thank you very much,
Alex

You dont need to cursors to show the entities as columns. It can be done using set based code. The concept is called cross tabbing or pivoting
See this examples
www.mssqltips.com/sqlservertip/1019/crosstab-queries-using-pivot-in-sql-server/
https://www.simple-talk.com/sql/t-sql-programming/creating-cross-tab-queries-and-pivot-tables-in-sql/
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • How to encrypt column of some table with the single method  on oracle7/814?

    How to encrypt column of some table with the single method on oracle7/814?

    How to encrypt column of some table with the single method on oracle7/814?

  • How to encrypt column of some table with the single method ?

    How to encrypt column of some table with the single method ?

    How to encrypt column of some table with the single
    method ?How to encrypt column of some table with the single
    method ?
    using dbms_crypto package
    Assumption: TE is a user in oracle 10g
    we have a table need encrypt a column, this column SYSDBA can not look at, it's credit card number.
    tha table is
    SQL> desc TE.temp_sales
    Name Null? Type
    CUST_CREDIT_ID NOT NULL NUMBER
    CARD_TYPE VARCHAR2(10)
    CARD_NUMBER NUMBER
    EXPIRY_DATE DATE
    CUST_ID NUMBER
    1. grant execute on dbms_crypto to te;
    2. Create a table with a encrypted columns
    SQL> CREATE TABLE te.customer_credit_info(
    2 cust_credit_id number
    3      CONSTRAINT pk_te_cust_cred PRIMARY KEY
    4      USING INDEX TABLESPACE indx
    5      enable validate,
    6 card_type varchar2(10)
    7      constraint te_cust_cred_type_chk check ( upper(card_type) in ('DINERS','AMEX','VISA','MC') ),
    8 card_number blob,
    9 expiry_date date,
    10 cust_id number
    11      constraint fk_te_cust_credit_to_cust references te.customer(cust_id) deferrable
    12 )
    13 storage (initial 50k next 50k pctincrease 0 minextents 1 maxextents 50)
    14 tablespace userdata_Lm;
    Table created.
    SQL> CREATE SEQUENCE te.customers_cred_info_id
    2 START WITH 1
    3 INCREMENT BY 1
    4 NOCACHE
    5 NOCYCLE;
    Sequence created.
    Note: Credit card number is blob data type. It will be encrypted.
    3. Loading data encrypt the credit card number
    truncate table TE.customer_credit_info;
    DECLARE
    input_string VARCHAR2(16) := '';
    raw_input RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
    key_string VARCHAR2(8) := 'AsDf!2#4';
    raw_key RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(key_string,'AL32UTF8','US7ASCII'));
    encrypted_raw RAW(2048);
    encrypted_string VARCHAR2(2048);
    BEGIN
    for cred_record in (select upper(CREDIT_CARD) as CREDIT_CARD,
    CREDIT_CARD_EXP_DATE,
    to_char(CREDIT_CARD_NUMBER) as CREDIT_CARD_NUMBER,
    CUST_ID
    from TE.temp_sales) loop
    dbms_output.put_line('type:' || cred_record.credit_card || 'exp_date:' || cred_record.CREDIT_CARD_EXP_DATE);
    dbms_output.put_line('number:' || cred_record.CREDIT_CARD_NUMBER);
    input_string := cred_record.CREDIT_CARD_NUMBER;
    raw_input := UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
    dbms_output.put_line('> Input String: ' || CONVERT(UTL_RAW.CAST_TO_VARCHAR2(raw_input),'US7ASCII','AL32UTF8'));
    encrypted_raw := dbms_crypto.Encrypt(
    src => raw_input,
    typ => DBMS_CRYPTO.DES_CBC_PKCS5,
    key => raw_key);
    encrypted_string := rawtohex(UTL_RAW.CAST_TO_RAW(encrypted_raw)) ;
    dbms_output.put_line('> Encrypted hex value : ' || encrypted_string );
    insert into TE.customer_credit_info values
    (TE.customers_cred_info_id.nextval,
    cred_record.credit_card,
    encrypted_raw,
    cred_record.CREDIT_CARD_EXP_DATE,
    cred_record.CUST_ID);
    end loop;
    commit;
    end;
    4. Check credit card number script
    DECLARE
    input_string VARCHAR2(16) := '';
    raw_input RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
    key_string VARCHAR2(8) := 'AsDf!2#4';
    raw_key RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(key_string,'AL32UTF8','US7ASCII'));
    encrypted_raw RAW(2048);
    encrypted_string VARCHAR2(2048);
    decrypted_raw RAW(2048);
    decrypted_string VARCHAR2(2048);
    cursor cursor_cust_cred is select CUST_CREDIT_ID, CARD_TYPE, CARD_NUMBER, EXPIRY_DATE, CUST_ID
    from TE.customer_credit_info order by CUST_CREDIT_ID;
    v_id customer_credit_info.CUST_CREDIT_ID%type;
    v_type customer_credit_info.CARD_TYPE%type;
    v_EXPIRY_DATE customer_credit_info.EXPIRY_DATE%type;
    v_CUST_ID customer_credit_info.CUST_ID%type;
    BEGIN
    dbms_output.put_line('ID Type Number Expiry_date cust_id');
    dbms_output.put_line('-----------------------------------------------------');
    open cursor_cust_cred;
    loop
         fetch cursor_cust_cred into v_id, v_type, encrypted_raw, v_expiry_date, v_cust_id;
    exit when cursor_cust_cred%notfound;
    decrypted_raw := dbms_crypto.Decrypt(
    src => encrypted_raw,
    typ => DBMS_CRYPTO.DES_CBC_PKCS5,
    key => raw_key);
    decrypted_string := CONVERT(UTL_RAW.CAST_TO_VARCHAR2(decrypted_raw),'US7ASCII','AL32UTF8');
    dbms_output.put_line(V_ID ||' ' ||
    V_TYPE ||' ' ||
    decrypted_string || ' ' ||
    v_EXPIRY_DATE || ' ' ||
    v_CUST_ID);
    end loop;
    close cursor_cust_cred;
    commit;
    end;
    /

  • I have sent my iPod back for servicing because it is cracked, with some dispute with Apple I have managed to get a brand new iPod Touch. Just wondering if anyone has had this problem how long did it take from "Replacement Product Pending" to get bck to UK

    I have sent my iPod back for servicing because it is cracked, with some dispute with Apple I have managed to get a brand new iPod Touch. Just wondering if anyone has had this problem how long did it take from "Replacement Product Pending" to get back to the UK

    Not really. Is say "pending"
    pend·ing 
    /ˈpendiNG/
    Adjective 
    Awaiting decision or settlement.
    Preposition
    Until (something) happens or takes place: "they were released on bail pending an appeal".
    Synonyms
    adjective. 
    pendent - undecided - unsettled - outstanding - pendant
    preposition. 
    during - until - till - to

  • Database Adapter: cannot access table with complex record type as columns

    Hi all,
    I cannot perform any operations on a table that has columns with complex record type.
    I have created a table to store purchase order details.
    Sample script:
    CREATE type XX_CUST_INFO_TYP as object
    ssn VARCHAR2(20),
    rating NUMBER(15)
    CREATE type XX_ITEM_TYP as object
    item_name VARCHAR2(20),
    unit_price NUMBER(15),
    quantity NUMBER(15)
    CREATE table XX_PORDER (cust XX_CUST_INFO_TYP, porder XX_ITEM_TYP);
    When i try to access the table X_PORDER in jdev through a database Adapter, i receive the error as
    "some tables contains columns that are not recognized by the database adpter"
    1.) so in this case, how to include such tables that have complex types?
    Also, check out this scenario also..
    1. add a table through a database adapter
    2. drop the table in backend
    3. i can still see the table and its structure in the database adapter wizard even after restarting Jdeveloper.. How is it possible?
    These are some really interesting scenarios to experiment. Please suggest your ideas on this..
    Thanks All!

    Hi Hem,
    for a select you could select against a view. And for inserts you could create a stored procedure. They support complex types since 10.1.2. Complex types support in tables/views was added for 11 (next major release).
    You might be able to use PureSQL as a workaround too, i.e.
    insert into XX_PORDER values (XX_CUST_INFO_TYP(?,?), XX_ITEM_TYP(?, ?, ?))
    As for your other problem, in 10.1.2/10.1.3 the DBAdapter wizard sits on top of the Jdev Offline Tables and TopLink Mapping Workbench components. When you remove a table in the wizard it won't delete the Offline DB component. It was added by the wizard, but afterwards it is public to the entire Jdev project. You must remove it from Jdev yourself. This has been improved for the next major release too, no artifacts from underlying components are created.
    To remove it select:
    Offline DB Objects -> <schema> -> <table> and try File.. Erase From Disk.
    Thanks
    Steve

  • Why updates on some tables with always on synchronize mode take * 100 than when asynchronize mode

    I have Always-On synchronization on some databases, We want to change from asynchronize mode to synchronize mode, I tested to see what the  change in performance between the two, and found that in general the select statements keep the same
    duration with and without synchronize mode, most of the update\insert usually take around * 4 times from the asynchronize mode, BUT some updates take much longer. I would like to understand why things take MUCH longer (I understand that working with synchronize
    mode is a 2 phase commit and should take * 4 times, but I can't understand why some of them take 50 - 100 times more).
    1. One query is an update made on a table with few records (up to 40 records), this update run 250K times a day, and a very simple update on this table takes * 98 than without synchronize mode
    1. An update on a big table with 2 million records, using a query that specify the unique column in the primary cluster key, takes 50 times more.
    What are  the factors that have dramatic influence on performance when 2 phase commit (asynchronize mode) is used?

    I've never even looked at the details for SQL Server, but on any kind of a system doing synchronous updates, you have to figure there is a fixed cost, a variable cost, and a queuing cost.  The fixed cost always hits whether its a big transaction or
    a small transaction, let's guess it's about 0.1 seconds for a round trip.  Variable cost depends on how much is updated, let's say it's linear, and is maybe 0.05 seconds for a couple of small rows.  The queuing cost varies from 0 to huge.
    So if you have a small transaction on a local system that takes 0.05 seconds (50 milliseconds), then just one will incur the local 0.05, plus 0.10, plus 0.05, and zero queuing cost, so 0.05 -> 0.20, about 4x.
    But if you have something that runs 250k times a day I hope it's faster, maybe it's only 0.01 seconds locally, and that turns to 0.01 + 0.10 + 0.01 + q, so 0.01 -> 0.12+q, so it's at *least* 12x slower, and maybe if you get 100 of them
    in the same second you start incurring queuing delays also, in fact you may have similar queuing delays on the local system and remote system besides any communications queuing, but if just the synchronization system has some queuing limits and it even gets
    to 0.30 seconds then 0.01 -> 0.42, or 42x, and you start seeing what can happen.  If your local transaction is only 0.001 seconds when not synchronized, then you'd have 100x slowdown just on the fixed overhead!
    IOW, synchronized systems and tons of small, fast transactions just don't fit together very well.
    HTH,
    Josh

  • Recover some tables with RMAN

    Hi all.
    I want to recover some tables to some point in time and I have a hot backup of my DB. I want to preserve them. I want to know if this is possible or there is a better method:
    1.-Duplicate the database.
    Question: Can I duplicate only the schema with the tables? Because the tablespace is quite big and I don't want to recover it completely, I don't have much disk space. I will skip the other tablespaces. I don't know if it's possible because as far as I know RMAN recover allways the entire tablespaces.
    2.-Export the tables.
    3.-Import them in another schema in target DB.
    Oracle: 10g
    Best regards.

    Export or Datapump is a good option.
    RMAN will not full fill the requirementBut I used RMAN for the backup. I have to use it to do the restore. I only want to know if I am doing the restore correctly and if I can do the restore only of the tables I need.
    Thanks.

  • ORA-28113 policy predicate has error when created VO with some tables

    When I created a VO with just SQL statements(no EO), if the sql statements included some special tables or views such as:
    hz_locations
    oe_order_headers_v
    when testing the validation of the sql statement, I encountered the following errors:
    SQL Query Error Message: ORA-28113 policy predicate has error
    and I can't continue to create this VO.
    Does JDeveloper have some special rules to check some tables or views behind the scenes?
    I used the apps/apps to connect and the following sql to create the VO:
    select state from hz_locations
    Can anyone give some help?
    Many thanks in advance!

    Hi prasannaj,
    Thanks for your prompt response.
    I find the solution and would like to share with all.
    As I guessed, this is related to the policy.Execute the following sql:
    select * from dba_policies where object_name ='hz_locations'
    you'll find the point.
    So I run policy manager with oracle database client, and find the policy related to the table 'hz_locations' , and disable this policy.
    At this time, with the original sql:
    select * from hz_locaitons
    created VO and everything goes fine and passed the validation.
    But in fact I wondered if this is the best workaround for this issues.
    If anyone has the same problem, you can refer to my solution.
    If you have better solution, also let me know.
    Thanks!

  • How to Export only some tables with procedures and packages

    Hi...
    I want to export only some tables and packages and procedures. Can anybody please guide me how to do this.
    Thanks in advance.......
    pal

    could you please more elobarate in your question? do you want to export data from tables or you want to get the table structure, source of procedures and packages?
    Thanks
    M Thiyagarajan

  • How to clone data with in Table with dynamic 'n' number of columns

    Hi All,
    I've a table with syntax,
    create table Temp (id number primary key, name varchar2(10), partner varchar2(10), info varchar2(20));
    And with data like
    insert itno temp values (sequence.nextval, 'test', 'p1', 'info for p1');
    insert into temp values (sequence.nextval, 'test', 'p2', 'info for p2');
    And now, i need to clone the data in TEMP table of name 'test' for new name 'test1' and here is my script,
    insert into Temp  select sequence.nextval id, 'test1' name, partner, info from TEMP where name='test1';
    this query executed successfully and able to insert records.
    The PROBLEM is,
    if some new columns added in TEMP table, need to update this query.
    How to clone the data with in the table for *'n' number of columns and*
    some columns with dynamic data and remaining columns as source data.
    Thanks & Regards
    PavanPinnu.
    Edited by: pavankumargupta on Apr 30, 2009 10:37 AM

    Hi,
    Thanks for the quick reply.
    My Scenario, is we have a Game Details table. When ever some Game get cloned, we need to add new records in to that Table for the new Game.
    As, the id will be primary key, this should populate from a Sequence (in our system, we used this) and Game Name will be new Game Name. And data for other columns should be same as Parent Game.
    when ever business needs changes, there will be some addition of new columns in Table.
    And with the existing query,
    insert into Temp (id, name, partner, info) select sequence.nextval id, 'test1' name, partner, info from TEMP where name='test'_
    will successfully add new rows but new added columns will have empty data.
    so, is there any way to do this, i mean, some columns with sequence values and other columns with existing values.
    One way, we can do is, get ResultSet MetaData (i'm using Java), and parse the columns. prepare a query in required format.
    I'm looking for alternative ways in query format in SQL.
    Thanks & Regards
    PavanPinnu.
    Edited by: pavankumargupta on Apr 30, 2009 11:05 AM
    Edited by: pavankumargupta on Apr 30, 2009 11:05 AM

  • Problem with Pivot Table with Graph: Line Bar Combo

    Hello people!
    I have a problem with pivot table and line bar combo (all in the same view (pivot table))
    I have some measures and one dimension in my report.
    --------------measure1---measure2---measure3
    Dim A.1
    Dim A.2
    Dim A.3
    If I choose my graph line bar combo automatically choose "line" measure 3 (last measure in "Show Controls"). How can I do if I want my measure1 for line and I don't want modify my pivot table?
    Thank you very much!

    Ok, I'll explain my problem again. In my pivot table I add graph vision and I want in the same view (Pivot table). My graph is "Line Bar Combo" and I don't know how but the last of my measures belongs to right AXIS, if I change order of my measures I can see in my graph the measure that I want in my right axis BUT also it changes the order of my pivot table.
    This is my problem. I think that I can do that with different views but I lose my selector view to view graphic and my pivot table at the same time.

  • Export with expdp tables with name like 'name1%' or like 'name2%'

    How can I export data and metadata only from tables with name like 'name1%' or like 'name2%'
    what value must have INCLUDE parameter ?
    from one match it is
    INCLUDE=TABLE:"LIKE 'REF%' "
    this exports tables witch name begins with REF, but I need tables REF and REF1
    if I write like this:
    INCLUDE=TABLE:"LIKE 'REF%' ",TABLE:"LIKE 'REF1%' "
    or
    INCLUDE=TABLE:"LIKE 'REF%' "
    INCLUDE=TABLE:"LIKE 'REF1%' "
    it says that
    Total estimation using BLOCKS method: 0 KB
    ORA-39168: Object path TABLE was not found.
    ORA-31655: no data or metadata objects selected for job
    I supose such constructions work like between them is logical AND.
    I need an OR construction.

    C:\>EXPDP SCOTT/TIGER DIRECTORY=DATA_DIR DUMPFILE=EXPDATA.DMP INCLUDE=TABLE:"LIK
    E'REF%'"
    Export: Release 10.1.0.2.0 - Production on Saturday, 07 October, 2006 9:38
    Copyright (c) 2003, Oracle.  All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Produc
    tion
    With the Partitioning, OLAP and Data Mining options
    FLASHBACK automatically enabled to preserve database integrity.
    Starting "SCOTT"."SYS_EXPORT_SCHEMA_01":  SCOTT/******** DIRECTORY=DATA_DIR DUMP
    FILE=EXPDATA.DMP INCLUDE=TABLE:LIKE'REF%'Estimate in progress using BLOCKS method...
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 192 KB
    Processing object type SCHEMA_EXPORT/TABLE/TABLE
    . . exported "SCOTT"."REF123" 9.406 KB 10 rows
    . . exported "SCOTT"."REF12345" 9.414 KB 10 rows
    . . exported "SCOTT"."REF1ABC" 9.406 KB 10 rowsMaster table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
    Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
      C:\EXPDATA.DMP
    Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at 09:38
    C:\>
    INCLUDE=TABLE:"LIKE 'REF1%'
    no need to specify "ref1%" bcoz if u specify "ref%" it means all tables after "ref" will be export.

  • Problem with some files with Adobe Audition 3.0

    Hello everybody, I have a problem with some files. For example, when I open a .mp3 file, it says "The selected file it's not a supported file type". Instead, with other .mp3 files all works fine. What should I do? Thanks for the attention.

    I strongly suggest - in fact this is probably the only thing you can do at this point - that you have a look at the FAQ here, and do exactly what it says.

  • Create a View with many tables with the Table-Fieldnames

    Hello!
    Question 1)
    Which kind of view is the correct for joining
    many tables together.
    Question 2)
    What is the solution in case of having several tables
    with the same fieldnames by creating a view. How can I choose this fields
    into a view. I cant use the same name twice in section
    (tab strip) ViewFlds.
    Regards
    Ilhan

    Hi Ilhan,
    There is no problem in the view fieldname you can put something like this :
    This is you who choose the view field name so...
    View Fieldname         Table           Field
    VBAK_VBELN           vbak             vbeln
    vbap_vbeln                 vbap             vbeln
    Erwan

  • Migrating MySQL5 database to Oracle 10g - table with blob data fails

    During data migration phase from MySQL5 to Oracle, noticed that the tables that have record length greater than 64K fails. It just says FINISHED for those tables without migrating any data. This is specially happening in the tables that have text and blob columns with data more than 20Meg in the blob fields.
    Is this a bug? If not is ther any configuration file to increase the record size? Does it use SQL*Loader underneath to transfer the data or some other mechanism?

    Thanks Spain, but using Offline scripts does not work for me as my record length is around 28MB and SQL*loader allows maximum record length of 20MB.
    Is there any way to dump just the blob column data out of MySQL into a separate file?

Maybe you are looking for

  • Cannot locate file, even after it's copied to itunes

    I download a mp3 from a radio show I like everyday. I use to be able to download the file to my desktop, and then drag it to the right playlist in itunes. After it's in itunes, I would delete the one on the desktop and I would have it in my library a

  • How to get the namae of the month given its respective number

    Hi,     I am Asia and am a new member to this site. Please let me know if any function module to get the name of the month given its respective number. Thanks & Regards, Asia

  • Utilization / Chargeability report in CATS

    Is there any Utilization / Chargeability report in CATS.

  • Using gradients with the gradient mesh tool

    So I have a basic knowledge of using the gradient mesh tool, but in my current project I need the gradients within the object to fade from black to transparent (it will be used for a one-color tshirt).  I've tried to do this a couple different ways. 

  • Switching from Windows OS

    Hi, I am thinking to switch from windows to mac. I have a couple of questions regarding to that. I will be glad to have your answers. - I am considering to buy Microsoft Office for mac, student version. However, I will have two macs at home, should I