Set Primary Key when normalizing data?

Greetings all,

I have created an SSIS package that takes data from a very large table (301 columns) and puts it in a new database in smaller tables. I am using views to control what data goes to the new tables. I also specified that it drop the destination table and recreate it prior to copying the data. The reason for this is so that old data removed from the larger database will get removed from the normalized databases.

I have 2 things I am trying to figure out..

1. I would like to have the package set a specific row in each new table to be the primary key (this will allow us to use relationships when querying the data).

2. I decided I wanted to sort the data as it copies. I am using the BI Visual Studio for my editing. In the Data Flow view I cannot seem to disconnect the output from the Source block so I can connect it to the Sort block and then feed that to the output block. What am I missing here

Thanks



Answer this question

Set Primary Key when normalizing data?

  • IanMixxxqqq

    Thanks. It all looks good now.
  • bvrkchowdary

    I am not strong on the SQL programming skills. I am taking a Import/Export Wizard generated package and modifying it. I am not sure how I would go about a delete or truncate to eliminate either all of the data or just the data that no longer exists.

    I did manage to get the sorts in place.


  • FA65

    Jamie Thomson wrote:

    Would it not be easier to just issue a DELETE or TRUNCATE

    I am using all of the data so I do not want to kill any of it. I just want to spread it out for easier reference on webpages and such.

    Jamie Thomson wrote:

    Pardon Primary keys are formed of columns, not rows.

    Your right, I mean column.

    Jamie Thomson wrote:

    Presumably by "block" you are talking about components. Its not possible to drag a data-path from one component to another though it would be very nice if you could. Instead, simply delete the data-path and create a new one in its place that goes to the SORT component.

    You are correct and I will give that a try.

    Thank you


  • Stiner

     Autox wrote:

     

        I have created an SSIS package that takes data from a very large table (301 columns) and puts it in a new database in smaller tables.  I am using views to control what data goes to the new tables.  I also specified that it drop the destination table and recreate it prior to copying the data.  The reason for this is so that old data removed from the larger database will get removed from the normalized databases.

    Would it not be easier to just issue a DELETE or TRUNCATE  

     Autox wrote:

    I have 2 things I am trying to figure out..

    1.  I would like to have the package set a specific row in each new table to be the primary key (this will allow us to use relationships when querying the data).

    Pardon Primary keys are formed of columns, not rows.

     Autox wrote:

    2. I decided I wanted to sort the data as it copies.  I am using the BI Visual Studio for my editing.  In the Data Flow view I cannot seem to disconnect the output from the Source block so I can connect it to the Sort block and then feed that to the output block.  What am I missing here

     

    Presumably by "block" you are talking about components. Its not possible to drag a data-path from one component to another though it would be very nice if you could. Instead, simply delete the data-path and create a new one in its place that goes to the SORT component.

    Hope that helps.

    -Jamie

     



  • Tall Dude

     Autox wrote:
     Jamie Thomson wrote:

    Would it not be easier to just issue a DELETE or TRUNCATE  

    I am using all of the data so I do not want to kill any of it.  I just want to spread it out for easier reference on webpages and such. 

    Sorry, you've lost me. I mean delete it from the destination. How is this any more destructive than dropping the table

     Autox wrote:

     Jamie Thomson wrote:

    Pardon Primary keys are formed of columns, not rows.

    Your right, I mean column.

    You define the primary key when you create the table. If you just truncate the table instead of dropping it then you wouldn't have to redefine the primary key.

     Autox wrote:

     Jamie Thomson wrote:

    Presumably by "block" you are talking about components. Its not possible to drag a data-path from one component to another though it would be very nice if you could. Instead, simply delete the data-path and create a new one in its place that goes to the SORT component.

    You are correct and I will give that a try.

    Thank you

     I hope that helps and it didn't sound rude. I'm just not sure if you're approaching this in the right way.

    -Jamie

     



  • MonkWebs

    Oh OK. Fair enough.

    Truncating the table and deleting the contents of it have the same basic effect. I won't go into the differences here. the commands are:

    TRUNCATE TABLE <table_name>

    or

    DELETE FROM <table_name>

    The command would go in an Execute SQL Task.

    -Jamie



  • Set Primary Key when normalizing data?