Performance And Data Structure Question

Feb 2, 2006

Hi SQL gurus,


I have a table structure question. I will have a table 'Models' that
has one to many 'incomes' and one to many 'costs'. These 2 entities
have exactly the same structure, which is 7 smallmoney and a name. Is
it better to create a table 'Incomes' and a table 'Costs', with both
the same number of fields like this :


Incomes
-------------
in_idmodel
in_1
in_2
in_3
in_4
in_5
in_6
in_7
in_name


Costs
-------------
c_idmodel
c_1
c_2
c_3
c_4
c_5
c_6
c_7
c_name


or is it better to create one single table that will contain both
entities like that :


Incomes_Costs
-------------
ic_idmodel
ic_1
ic_2
ic_3
ic_4
ic_5
ic_6
ic_7
ic_name
ic_isIncome


which only differs from the 2 above by the isIncome field to know which

row is an income and which row is a cost.


I'd like to know which method is the best in terms of performance and
general structure and would greatly appreciate if you explain a little
the reasons that drove you to suggest me a method over the other.


Thanks all for your time!


ibiza

View 4 Replies


ADVERTISEMENT

Data Structure -- It's Been A While

Jul 20, 2005

Ok, I haven't been doing too much database work lately and my brain has gonesoft.I need some help with proper structure.My database is being used to track television shows.Any given show will be associated with at least one production company (callit ProdCo) but possibly up to 3 production companies (never more than that).I have:tblNetworkNetID (numeric, Identity)NetName (char, 50)tblShowDataBookingNum (numeric, Identity)BookingNumExt (numeric, Identity)Now, if I was just dealing with one ProdCo I would add it tblShowData as aforeign key from tblNetwork; no problem.How do I structure it so that I can combine 1 to 3 ProdCo's as one referencein tblShowData.I tried:tblNetworkComboID (numeric, Identity)Net1Net2Net3The problem is, obviously I can only join the FK from tblNetworks to one ofthe NetX fields in tblNetworkCombo.I don't quite know where to go from here. Any help would be appreciated.

View 3 Replies View Related

Duplicating Db Structure Without Data

Oct 28, 2004

i have a database on one server that I want to duplicate on a new server. I do not want to copy the data only the structure.

I created some SQL scripts from the current db as I have read that is what I should do.

My question is where do I use this script on my new server to create the new tables etc..

Do i use the import feature. Where do I run my sql script?


thanks

View 2 Replies View Related

Replicating Structure As Well As Data

Dec 27, 1999

Are there any known problems with replicating structure changes (New table, etc...), as well as data in MSSQL Server 7.0?

View 2 Replies View Related

Exporting Data+Structure

Mar 4, 2004

Hello E'body,

I have to export a SQL Server Table (Structure+Data) to an access mdb file at run time. How can i do it? please help.

Lax.

View 1 Replies View Related

Can't Change Data Structure

Nov 14, 2014

I have a database (MSSQL). To demonstrate the problem let me show a fictive Tablestructure. I don't want to discuss about how to save the data differntly, because the structure is fix and I can't change it.To get this result I would do a sql query with a lot of joins like that:

SELECT firstname, lastname, email.value, phone.value
FROM Customer
INNER JOIN
(
SELECT Customer_Properties.id, Customer_Properties.value
FROM Customer_Properties

[code]...

I don't think that this is really performant and the SQL-Queries get very complicated. Give it a other methode for that? I can't change the data structure.

View 3 Replies View Related

DATA STRUCTURE MIGRATION

Apr 23, 2008

Hi
Can Any one help me out of this in my project I have to migrate only datastructure or schema and not the data inside the table using SSIS. How can I do that ?

View 9 Replies View Related

Replicating Structure Only Not Data

Dec 1, 2006

I have a SQL 2005 database that I am using with a website. This basic website will be sold to other companies and ran on their servers with different URLs. Since, All of these databases will store different data, I'm not sure how I can make updates to original database and replicate those structure changes to the other DBs without changing the data also. Is there a way to automate the replication of structural DB changes without replicating the data along with it?

Thanks,

Kirk

View 5 Replies View Related

Copy Table Structure Only - Not Data

Oct 18, 2007

We have SQL Enterprise Manager (8.0).  Is there any way to Copy a Table from one database to another with only the Structure (design) - not all the Data? 
I can't find any option in the Import Data Wizard that only copies the Table structure.
 Any help is appreciated.  Thanks
 

View 1 Replies View Related

Accessing Data Structure Of A MS SQL Database

Mar 19, 2008

I have written 5 content-management systems and am getting a little bored writing a lot of the same functionality and tweaking it for different datamodels.  Is there a way within .NET to have visibility of a database's structure (ie, data type, column names, foreign keys etc)?  I'd like to write up a dynamically generated form for any given table, displaying appropriate form controls based on data type and foreign keys.

View 7 Replies View Related

Question On Data/structure Restore

Sep 20, 2006

new to SQL Server 2000. We have an obsolete database that we need to
save off for x number of years. DB2 has utilities (DB2Look/Export)
that allows for the export of the data along with a schema and script
that enables the future recreation of the structure of the databases
and tables to include RI etc. You can save off the architecture and
relationships of the tables as well as the data.

Does SQL Server have anything similar?

Failing that, our plan is to backup the data and logs then image the entire disk.

Thanks in advance.

Gerry

View 8 Replies View Related

Changing The Structure Of Data In A Table

Feb 20, 2004

I have a table that looks like this:

ID Type
123 Phone
123 Meeting
123 Phone


and I would like the data to look like this

ID phone Meeting
123 2 1


How do I do this?

View 3 Replies View Related

Copying Data And Structure From One Database To Another

Jul 23, 2005

Hi all!I have an application that needs to copy the database structure fromone database to another without using the "Generate SQL Script"function in Enterprise Manager. I'd like to do this from within astored procedure. Can someone recommend the best approach for this?I've seen references to using SQL-DMO from a stored procedure using thesp_OA* procs in other postings to this group but was wondering if therewas an easier way? Can I use bcp and then use xp_cmdshell from withinmy stored procedure? It's not clear to me from the documentationwhether bcp copies both structure and data or just data? Is there abetter way?Thanks in advance for any help!Karen

View 1 Replies View Related

Large Export Of Data From One DB Of One Structure To Another

Aug 31, 2006

Hi guys,

Hopefully this is the right place to ask.

Basically we have have two larges databases, one of which is updated from the other monthly.

For exaplination purposes:

DB1 = Source DB

DB2 = Destination DB

The problem that I require a soltion to is, how do I insert rows from a table in DB1 to DB2 and recover and store the identity of the new row against the ID of the existing row. This is so that I can then matain constraints when it comes to inserting rows into the next table and the next and so on.

This process of storing the ID's as lookups will need to be done for almost every table of which there are 20.

The best Idea we have at the minute is to create a table with two colums for each table (drop it and recreate it after each table has exported) that contains the two ID's, new and old.

This will require using a cursor for each row in the existing table, inserting it in the new table and the using @@Scope_Identity to get the new ID and then insert the two values into the temp table.

This too me feels like it will be very slow, particuarly when I bear in mind how much data we have.

Does anyone have any better ideas? (Sorry if the explaination isn't great, its difficult to get accross)

Thanks

Ed

View 1 Replies View Related

Copy Just The Database Structure Not The Data

Feb 19, 2007

I have been working on my windows app, using SQL Server 2005 (& C#) but I now have loads of junk data, so I want to copy the structure without any data to a new set of files that can become the production version.

I assume I can use backup and restore in future when I want a copy of my production data to use for future testing.

How would I take just one table from my test database and add it to my production database without retyping the design?

Apart from the size limitation is there any advantage in buying a version of SQL Server over using the Express edition?

View 1 Replies View Related

Copy Database Structure But Not The Data

Feb 13, 2008

I'm looking to create a new version of a database but with completely reloaded data - so I want to retain the database structure but none of the data.

Is there an easy way (read: without a DBA on staff) to copy an existing database structure - preferably with views and stored procedures - and not take the data along for the ride?

Thanks in advance for suggestions...!

View 7 Replies View Related

Moving Data To A Table With A Different Field Structure

Sep 25, 2003

In order to export data to a 3rd party provider, I build five separate tables to store the data. Every table has a different layout, except for the first four columns. They are record type, SSN, employee id and another id number.

Basically, I have to sort that data by SSN then by record type. Each employee will have multiple records.

However, that data will need to be "merged" into one table to be exported.

I have created a table that defines the first four columns, but then has one large "filler" field that will contain the rest of the data. How can I copy data from five different tables with five different layouts into one table?

Any suggestions?

Thanks,
Steve Hanzelman

View 6 Replies View Related

Automating Validation Of Structure / Data Of CSV File

Feb 15, 2013

We have the following scenario: We receive CSV files every month for which SSIS packages were built to process the data. The following problems occur from time to time:

1. The structure of the CSV file changed (e.g. column added or removed)
2. There were no footers in the data, but now footers started to appear
3. Date format changed (e.g. used to be mm/dd/yyyy, but became mm.dd.yyyy)
4. Number format changed (e.g. from 2000 to 2,000)

Currently we have person who manually opens each file, and using our "validation document" validates to ensure none of these or similar problems occur. We would like to move away from this manual process if possible. I understand that items 3. and 4. could be caught by loading data into a staging table with VARCHAR data types, and performing validation before moving it any further.

Item 2 is a bit questionable (meaning depending on the footer size SSIS load could fail or not).

Item 1, however, is a sure fail of the SSIS package that directly loads the data into a table.

Thus I feel the two possible options are:

1. Create a custom script that will run through the file, row by row, apply all the necessary validations and report an error or continue if all checks out

2. Use some 3rd party tool to validate the files (semi-manually) before kicking off the SSIS processing.

View 3 Replies View Related

Exporting Structure && Data To Access Table

Mar 11, 2004

Hello E'body

I have an application with MSAccess as front end and SQLServer as backend. have quite a bit of tables. i wanted to write a stored procedure which exports a SQL Server table (both Structure & Data) to a new Access MDB file. i know with the use of DTS its possible but i need to code it down. i need to perform this at runtime. so can anybody help.
Its urgent.

Bye.

Lax

View 1 Replies View Related

How To Copy Database Structure From One Db To Another W/o Affecting Data

Jul 23, 2005

Is there a way to copy the structure from one database to anotherwithout affecting the actual data?For example, I added new fields and stored procedures to a db in mydevelopment environment. There are a lot of them.I now want to make the same changes to my production environment db butdon't want to affect the data. Only the fields, stored procs &constraints and stuff pertaining to the structure of the db should bechanged.Does anyone know of a program that can do this or can this be done inMS SQL Enterprise Manager.Any help would be appreciated.7078895

View 2 Replies View Related

Data Warehousing :: Use New Table With Reduced Structure?

Aug 24, 2015

I have a large fact table spread across tens of partitions (appx. 1TB each). I found that the business does not need much of the columns in the table. So, as an optimization action, I decided to get rid of these un-needed columns.What is the efficient way to achieve this? Can I simply drop these columns from the table, or use a new table with the reduced structure?

View 2 Replies View Related

Purging A Database Data While Keeping The Structure Intact

Oct 15, 2006

Is it possible to purge all records in the database while retaining the the table structures. Even better yet, could I do it on a table by table basis?   If I simply delete all the records the identities for the tables do not revert back to 1.

View 2 Replies View Related

Insert, Update && Delete On Two Tables With Same Data Structure...

Jun 30, 2006

I have created two table with same data structure. I need realtime effects (i.e. data) on both tables - Table1 & Table2.

Following Points to Consider.

1. Both tables are in the same database.

2. Table1 is using for data entry & I wants the same data in the Table2.

3. If any row insert, update & delete occers on Table1, the same effect should be done on Table2.

4. I need real time data insert, update & delete on Table2.

I knew that using triggers it could be possible, I have successfully created a trigger for inserting new rows (using logical table "Inserted") in Table2 but not succeed for update & delete yet.

I want to understand how can I impletement this successfully without any ambiguity.

I have attached data structure for tables. Thanx...

View 10 Replies View Related

Retreiving Tree-Structure Data From A Table Throug

Apr 7, 2007

Hi all
I have a Table with Following structure ( a Tree Structure )

PK Parent Level Code
--- -------- ------- ------
1 0 0 100
2 1 1 101
3 1 1 102
4 2 2 103
5 3 2 104
6 4 3 105

The same as following Tree as you can see
1__
| 2__
| 4__
| 6
| __
3__
5

I need a query to return the following Result. I think it is possible only through Nested sub-Queries But i don't know how to do that
Could any one help me.?


PK Parent Level Value First-Parent' Code 2nd-Parent's Code 3rd-Parent's Code
---- -------- ------ ------- --------------------- ---------------------- -----------------------
1 0 0 100 NULL NULL NULL
2 1 1 101 100 NULL NULL
3 1 1 102 100 NULL NULL
4 2 2 103 101 100 NULL
5 3 2 104 102 100 NULL
6 4 3 105 103 101 100

Any help greatly would be appreciated.
Kind Regards.

View 2 Replies View Related

Table Structure And Data Transfer From SQL2000 To Access (.mdb)

Aug 8, 2006

Hello. I want to ask about the possibility of copying both a tablestructure and it's contents from aSQL server table to a table within MS access. The problem cannot besolve with a permanent table structure at the target location.The names of the columns are essentially data with the application andso are subject to change. I am targeting a solution using SQL QueryManager.The approach I have tried (with failure) isSELECT *INTO <linkedserver table>FROM <local table>This should create and copy. However, I am not sure if this isachievable with this approach.Refer to the dialogue;-------------------------------------------------------USE MASTERGOEXEC sp_addlinkedserver@SERVER = 'Freddie',@PROVIDER = 'Microsoft.Jet.OLEDB.4.0',@SRVPRODUCT = 'OLE DB Provider for Jet',@DATASRC = 'C: empHMIS_Recipe.mdb'-- I am not sure if this is requiredEXEC sp_addlinkedsrvlogin 'Freddie', false, 'sa', 'Admin', NULLSELECT * FROM Freddie...FRED -- This is OKSELECT * INTO #Temp FROM Freddie...FRED -- This is OK-- This fails - Refer errorSELECT * INTO Freddie.FRED65from #tempServer: Msg 2760, Level 16, State 1, Line 1Specified owner name 'Freddie' either does not exist or you do not havepermission to use it.-- This also fails and I thought reflected the above select with naming- Refer errorSELECT * INTO Freddie...FRED65from #tempServer: Msg 117, Level 15, State 1, Line 2The object name 'Freddie...' contains more than the maximum number ofprefixes. The maximum is 2.EXEC sp_dropserver 'Freddie',@droplogins = 'droplogins'------------------------------------------------------------Thank you.Regards JC...

View 3 Replies View Related

Data Source View Of Mining Structure Cant Be Edited?

Nov 23, 2006

Hi, all here,

Thank you very much for your kind attention.

I got a quite a strange problem with Mining structure for OLAP data source though. The problem is: I am not able to edit the mining structure in the mining structure editor. The whole data source view within the mining structure editor is greyed. Could please anyone here give me any advices for that?

Thank you very much in advance for any help for that.

With best regards,

Yours sincerely,

 

View 5 Replies View Related

Data Flow Source That Will Take A String Variable With Csv Structure?

Dec 21, 2006

I am able to use a custom script task to receive a MSMQ package and save the package contents to a flat file.

I can also use the bulk load task to push the flat file contents into a SQL table.

However, I would like to save the package contents to a variable (done, it works), and then pass that string variable to a data flow task for SQL upload. In other words, I don't see any reason to persist the msmq package contents to disk.

My question is: Which data flow source can I use that will accept a string variable? The string variable will then need to be processed with bulk load or an execute sql task.

Btw, the content of the string variable is a csv style string:

"01001","11/21/2006",15
"01001","11/21/2006",1
"01001","11/21/2006",25
"01001","11/21/2006",3


Thanks,

Trey

View 3 Replies View Related

Data Mining - Scalar Mining Structure Column Data Type Error...

May 31, 2006

Hoping someone will have a solution for this error

Errors in the metadata manager. The data type of the '~CaseDetail ~MG-Fact Voic~6' measure must be the same as its source data type. This is because the aggregate function is not set to count or distinct count.

Is the problem due to the data type of the column used in the mining structure is Long, and the underlying field in the cube has a type of BigInt,or am I barking up the wrong tree?

View 16 Replies View Related

Data Mining :: Content In Data Mining Structure Not Valid - Deployment Fails

Apr 30, 2015

I'm a beginner with SQL 2012 SSDT & SSMS. I get this error message when I try to deploy my project: 

"Error 6
Error (Data mining): KEY SEQUENCE columns are not supported at the case level. The 'Customer Key' column of the 'TK448 Ch09 Cube Clustering' mining structure contains content that is not valid.
0 0
"
I am finding it hard to locate the content that is not valid. I've been trying to find a answer for this problem but can't seem to find anything. How can I locate the content that is not valid and change or delete it so that I can deploy this solution?

View 2 Replies View Related

Any Structure On Sql Server Like WITH ... SELECT Structure On DB2

Jul 20, 2005

Hi,I'm using DB2 UDB 7.2.Also I'm doing some tests on SQL Server 2000 for some statements touse efectively.I didn't find any solution on Sql Server about WITH ... SELECTstructure of DB2.Is there any basic structure on Sql Server like WITH ... SELECTstructure?A Sample statement for WITH ... SELECT on DB2 like belowWITHtotals (code, amount)AS (SELECT code, SUM(amount) FROM trans1 GROUP BY codeUNION ALLSELECT code, SUM(amount) FROM trans2 GROUP BY code)SELECTcode, SUM(amount)FROM totalsGROUP BY code.............................Note: 'creating temp table and using it' maybe a solution.However i need to know the definition of the result set of Unionclause. I don't want to use this way.CREATE TABLE #totals (codechar(10), amount dec(15))GOINSERT INTO #totalsSELECT code, SUM(amount) FROM trans1 GROUP BY codeUNION ALLSELECT code, SUM(amount) FROM trans2 GROUP BY codeGOSELECT code, sum(amount) FROM #totals GROUP BY codeGOAny help would be appreciatedThanks in advanceMemduh

View 3 Replies View Related

Hierarchical (tree) Data Structure Where A Node Can Have Multiple Parents

May 9, 2008

Hi all!
I am trying to organize a hierarchical data structure into a table. I need to have the possibility to set 2 parents for some nodes. Curently I see following two options:
Example 1
id    parent_id    name-----------------------------------1     0                 Level 1 Parent A2     0                 Level 1 Parent B3     1,2              Level 2 Child
Example 2
id    parent_id    name-----------------------------------1     0                 Level 1 Parent A2     0                 Level 1 Parent B3     1                 Level 2 Child3     2                 Level 2 Child
Is any of the two examples valid database logic wise? In fact, is it possible to achieve the requirement by using only one table?
Thanks in advance,

View 4 Replies View Related

SQL 2012 :: SSIS - Updating Source And Target Data Structure

Feb 17, 2015

I have a SSIS package that simply moves data from a SQL database A to another SQL database B. I have update (increased) the size of a nvarchar column, on both A and B.I am wondering if there is a way to "refresh" somehow the SSIS package so I don't have to rebuild and redeploy it.The error I get now is a truncation error: "Text was truncated or one or more characters had no match in the target code page".

View 2 Replies View Related

SQL Server Admin 2014 :: Structure Of Log Saving (for Data Mining)

May 12, 2015

We saved huge log data from user behaviour in our site .

But In data mining time , we saw that most of them cant use for data mining

What is the best practice about data gathering from user movement in site?

is there any best practice Template for this ?

View 0 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved