|
Mycroft Holmes wrote: Sorry I missed the SQL Lite platform in the title That's okay. I could've qualified it further by stating it's running on an Android platform.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Ok
this is probably going to be the easiest answer you guys have ever given bit i am finding this concept difficult i guess it just isnt clicking
http://prntscr.com/3ps60e[^]
^picture of the table i have a question about
i am trying to fine the canidate key and the functional dependency in this table :/ i understand what a functional dependency is but cant figure out how it relates to this table for instance
CookieCost = NumberOfBoxes X $5
i know that cookie cost is functiolly dependent on the number of boxes
but yea i suppose if you could tell me the answer but more importantly HOW you got that i would REALLY appreciate it
|
|
|
|
|
Member 10865129 wrote: i know that cookie cost is functiolly dependent on the number of boxes That goes for all calculations, but that's not what's meant in the context of normalization.
Member 10865129 wrote: i am trying to fine the canidate key and the functional dependency in this table The table should be in 0NF first, in which case it needs a name. To find the candidate keys, you'd make a list of the fields that can be used to identify a unique record.
They look like meetings. What fields would the you combine to get a unique meeting - no, rephrase, which of those facts does the user require to uniquely identify an entry? If I'm not mistaken, then it's a compound key.
Next you'll be hunting for fields that are functionally dependent on a part of that key; they need to be moved to their own table (if there are any, and yes, I seen one) Ask yourself for each non-key field the question: "does this fact depend on the complete cadidate key, or is it determined by part of the candidate?"
Easy explanation; http://support.microsoft.com/kb/283878[^]
Complex explanation; http://en.wikipedia.org/wiki/Functional_dependency[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Member 10865129 wrote: more importantly HOW you got 0 NF:
Attorney | ClientNumber | ClientName | MeetingData | Duration | Boxer | 1000 | ABC, Inc | 11/5/13 | 2 | Boxer | 2000 | XYZ Partners | 11/5/13 | 5.50 | James | 1000 | ABC, Inc | 11/7/13 | 3 | Boxer | 1000 | ABC, Inc | 11/9/13 | 4 | Wu | 3000 | Malcomb Zoe | 11/11/13 | 7 |
1 NF:
* Remove all calculated facts
* Assign a key
* Move repeating groups to their own table
(key is underlined)
Attorney | ClientNumber | MeetingData | Duration | Boxer | 1000 | 11/5/13 | 2 | Boxer | 2000 | 11/5/13 | 5.50 | James | 1000 | 11/7/13 | 3 | Boxer | 1000 | 11/9/13 | 4 | Wu | 3000 | 11/11/13 | 7 |
ClientNumber | ClientName | 1000 | ABC, Inc | 2000 | XYZ Partners | 3000 | Malcomb Zoe |
2 NF:
* Find the attributes that are not "functionally dependent" on the entire key
That means that we look at each non-key field and ask ourselves whether or not it is depending on the entire key, or whether it can be identified with a part of that key.
The only non-key field in "Meetings" is called "Duration". The duration "2" belongs to the meeting that's identified with all three fields, so there's no functional dependency there. In the original table the duration could depend on a part of the key; my mistake.
3NF:
* Find non-key fields that depend on other non-key fields.
There's none.
One might argue that the Attorney is also a repeating group, and put it in it's own table with an artificial key.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have created SSIS package and deployed in SQL Server 2008 in a seprate server, and that package is called using ASP.NET which is different web server, in this web server i have already installed Integration Services, but still when i load the package i am getting below error message.
package errMicrosoft.SqlServer.Dts.Runtime.DtsComException: An Integration Services class cannot be found. Make sure that Integration Services is correctly installed on the computer that is running the application. Also, make sure that the 64-bit version of Integration Services is installed if you are running a 64-bit application. ---> System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {BA785E28-3D7B-47AE-A4F9-4784F61B598A} failed due to the
following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). at Microsoft.SqlServer.Dts.Runtime.Application..ctor()
can you please help if am missing any settings or runtime service to be installed in web server.
Below is my code that is used to execute the SSIS Package.
Dim pkg As Package
Dim app As Application
Dim pkgResult As DTSExecResult
app = New Application()
pkg = app.LoadFromSqlServer("\\" & SSISPackageName, DB_ServerAddress, Nothing, Nothing, Nothing)
pkgResult = pkg.Execute()
If (pkgResult = DTSExecResult.Failure) Then
For Each local_DtsError As Microsoft.SqlServer.Dts.Runtime.DtsError In pkg.Errors
Next
End If
Shuaib
|
|
|
|
|
Hello All,
I tried using '+' operator for left outer join in MySql Workbench 5.2 CE but it is giving me a syntax error.I want to know whether + operator is supported by MySql Workbench 5.2 CE or not?I have gone through the manual of workbench but I did not find any information on this topic.Kindly help me with it.
|
|
|
|
|
I'm pretty sure MySQL isn't supporting outer implicit joins, only inner implicit joins.
You'll have to use an Ansi Join instead.
|
|
|
|
|
Lots of companies are comparing the SSAS Tabular vs Multi-dimensional Model. Honestly, there are tons and tons of articles already written about the differences between the two (so i don’t plan on doing that). Case in Point: http://www.sqlchick.com/entries/2012/3/4/decisions-powerpivot-ssas-tabular-or-ssas-multidimensional-m.html
I recently worked in an environment where we were looking at using data-mining algorithms for product affinity analysis, linear regression and customer analysis for generating customer mailing lists.
Unfortunately, way back, the decision had been made to go with Tabular model, to take advantage of the the InMemory and speed of development benefits. Now, with tabular in place, requests starts coming for analysis that requires the construction of data-mining structures akin to what is in Multi-dimensional. Unfortunately, that functionality doesn’t exist in Tabular yet, so we can’t do the analysis unless we go Multi-dimensional.
Fortunately, this is not a show-stopper requirement for us but just something to be aware off.
Summary: Currently, tabular model does not support data mining structures required for product affinity analysis, linear regression, customer predictive analysis, e.t.c. I’m not sure if Microsoft plans on building such functionalities into Tabular model going forward, but I just wanted to point it out incase some people are not yet aware of this short coming for Tabular.
|
|
|
|
|
I am sick to the back teeth of encoding issues with MySQL. I have Googled the issue and tried every suggestion I can find, and am still plagued with insert errors such as:
ERROR [HY000] [MySQL][ODBC 5.1 Driver][mysqld-5.5.18]Incorrect string value: '\xEF\x82\xA7\x09Se...' for column '[column name]' at row 1
Please.. don't bother suggesting ways round this, I give up on it. My question, to anyone else who has experienced this, is simply this: does PostgreSQL suffer this same issue, or at least have a solution that works?
|
|
|
|
|
It will have different issues.
Your best bet is to make sure you install it to use Unicode. But watch out, PostGreSQL uses UTF8 while dotnet uses UTF16 internally. So you might still encounter odd issues.
MySQL supports UTF16 from version 5.5 IIRC.
Why do you use odbc instead of Connector/NET?
|
|
|
|
|
It was installed with utf8_geberal_ci as the default. With the later versions of MySQL supporting utf8mb4_general_ci I've tried that too - but to no avail.
Why ODBC? Habit, I guess. Would Connector/NET make a difference?
|
|
|
|
|
Wombaticus wrote: Would Connector/NET make a difference?
Mostly performance, and a lot of it.
Have you read this[^]?
|
|
|
|
|
Hi All,
I have the following query that is created by MS Access while creating report. But the query has lots of inner queries and joins. Can anybody please help in making this big query simple and by removing all the possible brackets and make it clean. Any type is very helpful. This query really taking a lot of time to understand it. Any link, tool name or way to solve it any help is very much helpful. Thanks in advance.
Here is the query.
SELECT so.EntityId, s.SponsorId, so.OrderId, so.ProgramId, so.ProgramYear, s.SponsorNbr,
s.SponsorNme, s.VendorNbr, s.MailFdpCde, dbo.Reference.RefCde, dbo.Reference.ExtCde, dbo.FDPSponsorApp.CurrentInd,
dbo.DeliveryPeriod.BegDte, dbo.DeliveryPeriod.EndDte, dbo.vwRef_fdpprogram.RefDsc, dbo.vwRef_fdpprogram.RefCde AS ProgramCde, dbo.Product.ProductCde,
dbo.Product.ShortDsc as ProductDsc, sod.QtyInv AS QtyRcv, dbo.Product.NetPackWt,
(CASE WHEN ((dbo.ProductCost.FixedCost IS NULL) OR (dbo.ProductCost.EntDrawInd= 653)) THEN ISNULL(dbo.ProductCost.WghtAvgCost, 0)
ELSE ISNULL(dbo.ProductCost.FixedCost,0) END) AS UnitCost,
[QtyInv]*(CASE WHEN ((dbo.ProductCost.FixedCost IS NULL) OR (dbo.ProductCost.EntDrawInd= 653)) THEN ISNULL(dbo.ProductCost.WghtAvgCost, 0)
ELSE ISNULL(dbo.ProductCost.FixedCost,0) END) AS ValueRcvd,
[NetPackWt]*[QtyInv] AS [Total Pounds], dbo.Contact.FirstNme, dbo.Contact.LastNme, dbo.Address.Addr1, dbo.Address.Addr2,
dbo.Address.City, dbo.Address.State, dbo.Address.ZipCde, dbo_Reference_1.RefDsc AS DeliveryType, so.DeliveryTypeId,
dbo.RefYearDefaults.DefValue AS BrownBoxFee, dbo_RefYearDefaults_1.DefValue AS DirectDiversionFee, dbo.Product.NetPackWt, s.VendorNbr,
s.FedEmpIdNbr
FROM dbo.RefYearDefaults AS dbo_RefYearDefaults_1
INNER JOIN (dbo.RefYearDefaults
INNER JOIN ((dbo.Reference
INNER JOIN ((dbo.Contact
INNER JOIN (dbo.Address
INNER JOIN (dbo.ProductCost
INNER JOIN (dbo.Sponsor s
INNER JOIN (dbo.FDPSponsorApp
INNER JOIN ((((dbo.FDPEntity
INNER JOIN dbo.SponsorOrder so ON dbo.FDPEntity.EntityId = so.LocationId)
INNER JOIN dbo.SponsorOrderDetail sod ON so.OrderId = sod.OrderId)
INNER JOIN dbo.Product ON sod.ProductId = dbo.Product.ProductId)
INNER JOIN dbo.DeliveryPeriod ON (so.DeliveryPeriodId = dbo.DeliveryPeriod.DeliveryPeriodId)
AND (so.ProgramYear = dbo.DeliveryPeriod.ProgramYear)) ON (dbo.FDPSponsorApp.EntityId =
so.EntityId) AND (dbo.FDPSponsorApp.ProgramYear = so.ProgramYear)) ON s.SponsorId = dbo.FDPSponsorApp.SponsorId) ON
(dbo.ProductCost.ProgramYear = dbo.FDPSponsorApp.ProgramYear) AND (dbo.ProductCost.ProductId = dbo.Product.ProductId)) ON dbo.Address.AddrId =
dbo.FDPSponsorApp.MailAddrId) ON dbo.Contact.ContactId = dbo.FDPSponsorApp.FdpCtcId) INNER JOIN dbo.vwRef_fdpprogram ON so.ProgramId =
dbo.vwRef_fdpprogram.RefId) ON dbo.Reference.RefId = s.SFMSObjectTypeId) INNER JOIN dbo.Reference AS dbo_Reference_1 ON so.DeliveryTypeId =
dbo_Reference_1.RefId) ON dbo.RefYearDefaults.ProgramYear = so.ProgramYear) ON dbo_RefYearDefaults_1.ProgramYear = so.ProgramYear
WHERE (((so.ProgramYear)= 2014) AND --so.EntityId = @SponsorEntityId AND
((dbo.FDPSponsorApp.CurrentInd)=1) AND ((sod.QtyInv)>0) AND ((dbo.RefYearDefaults.DefNme)='BrownBoxFee')
AND ((dbo_RefYearDefaults_1.DefNme)='DirectDiversionFee')) ORDER BY so.EntityId, s.SponsorNme, so.OrderId, Product.ShortDsc
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
What a bloody awful construct - I doubt there is any tool to change the structure other than manually coding it.
As you will know the data structure you should be able to identify the joins in there and move them to a more supportable format.
INNER JOIN TableName as Alias ON A.Field = B.field
OR
Move the entire database to SQL Server where there are tools to help build and tune the query.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes we moved everything in to SQL Server. But this query is left, the person who created this query for the report is not there any more in the organization.
I am trying my head out to create the same query without lot of brackets. Can you please help me if you have any idea.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
I would start from scratch using the SQL Server view builder to get the table in and the joins. SSMS may create something similar but it may create the joins in a non nested structure which is what you are looking for to make it a supportable syntax.
If nothing else works then winkle out the table hierarchy from the syntax and build it manually by putting the main transaction table into the from and manually adding te rest of the table required.
I would also consider creating some views to simplify the structure EG your SponsorOrderDetail could be turned into a view to include the product and sponsor details required for the query.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Well you only need to unwind and indent your parentheses to make it more readable.
Then keep in mind that :
SELECT *
FROM TableA
JOIN
(
TableB Join TableC On TableB.ID = TableC.ID
)
ON TableA.ID = TableB.ID Is the same as:
SELECT *
FROM TableB
JOIN TableC
ON TableB.ID = TableC.ID
JOIN TableA
ON TableA.ID = TableB.ID So your query could quickly be simplified to this:
SELECT
so.EntityId,
s.SponsorId,
so.OrderId,
so.ProgramId,
so.ProgramYear,
s.SponsorNbr,
s.SponsorNme,
s.VendorNbr,
s.MailFdpCde,
dbo.Reference.RefCde,
dbo.Reference.ExtCde,
dbo.FDPSponsorApp.CurrentInd,
dbo.DeliveryPeriod.BegDte,
dbo.DeliveryPeriod.EndDte,
dbo.vwRef_fdpprogram.RefDsc,
dbo.vwRef_fdpprogram.RefCde AS ProgramCde,
dbo.Product.ProductCde,
dbo.Product.ShortDsc as ProductDsc,
sod.QtyInv AS QtyRcv,
dbo.Product.NetPackWt,
CASE
WHEN dbo.ProductCost.FixedCost IS NULL OR dbo.ProductCost.EntDrawInd= 653 THEN ISNULL(dbo.ProductCost.WghtAvgCost, 0)
ELSE ISNULL(dbo.ProductCost.FixedCost,0)
END AS UnitCost,
CASE
WHEN dbo.ProductCost.FixedCost IS NULL OR dbo.ProductCost.EntDrawInd= 653 THEN ISNULL(dbo.ProductCost.WghtAvgCost, 0)
ELSE ISNULL(dbo.ProductCost.FixedCost,0)
END * [QtyInv] AS ValueRcvd,
[NetPackWt]*[QtyInv] AS [Total Pounds],
dbo.Contact.FirstNme,
dbo.Contact.LastNme,
dbo.Address.Addr1,
dbo.Address.Addr2,
dbo.Address.City,
dbo.Address.State,
dbo.Address.ZipCde,
dbo_Reference_1.RefDsc AS DeliveryType,
so.DeliveryTypeId,
dbo.RefYearDefaults.DefValue AS BrownBoxFee,
dbo_RefYearDefaults_1.DefValue AS DirectDiversionFee,
dbo.Product.NetPackWt,
s.VendorNbr,
s.FedEmpIdNbr
FROM
bo.FDPEntity
JOIN dbo.SponsorOrder so
ON dbo.FDPEntity.EntityId = so.LocationId
JOIN dbo.SponsorOrderDetail sod
ON so.OrderId = sod.OrderId
JOIN dbo.Product
ON sod.ProductId = dbo.Product.ProductId
JOIN dbo.DeliveryPeriod
ON so.DeliveryPeriodId = dbo.DeliveryPeriod.DeliveryPeriodId
AND so.ProgramYear = dbo.DeliveryPeriod.ProgramYear
JOIN dbo.FDPSponsorApp
ON dbo.FDPSponsorApp.EntityId = so.EntityId
AND dbo.FDPSponsorApp.ProgramYear = so.ProgramYear
JOIN dbo.Sponsor s
ON s.SponsorId = dbo.FDPSponsorApp.SponsorId
JOIN dbo.ProductCost
ON dbo.ProductCost.ProgramYear = dbo.FDPSponsorApp.ProgramYear
AND dbo.ProductCost.ProductId = dbo.Product.ProductId
JOIN dbo.Address
ON dbo.Address.AddrId = dbo.FDPSponsorApp.MailAddrId
JOIN dbo.Contact
ON dbo.Contact.ContactId = dbo.FDPSponsorApp.FdpCtcId
JOIN dbo.vwRef_fdpprogram
ON so.ProgramId = dbo.vwRef_fdpprogram.RefId
JOIN dbo.Reference
ON dbo.Reference.RefId = s.SFMSObjectTypeId
JOIN dbo.Reference AS dbo_Reference_1
ON so.DeliveryTypeId = dbo_Reference_1.RefId
JOIN dbo.RefYearDefaults
ON dbo.RefYearDefaults.ProgramYear = so.ProgramYear
JOIN dbo.RefYearDefaults AS dbo_RefYearDefaults_1
ON dbo_RefYearDefaults_1.ProgramYear = so.ProgramYear
WHERE so.ProgramYear= 2014
AND dbo.FDPSponsorApp.CurrentInd=1
AND sod.QtyInv > 0
AND dbo.RefYearDefaults.DefNme='BrownBoxFee'
AND dbo_RefYearDefaults_1.DefNme='DirectDiversionFee'
ORDER BY so.EntityId, s.SponsorNme, so.OrderId, Product.ShortDsc Note that since the parentheses are gone the optimizer isn't forced to do the joins in a certain order anymore and might therefore be much faster.
|
|
|
|
|
Did you use a tool for that or manually code it?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Both, We have a homebrewed tool for formatting, the conversion of the joins I made by hand.
|
|
|
|
|
Awesome thanks a lot. I cant forget this help. Thank you thank you thank you very much.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
|
Actually this query isn't done by me but the person who did it wrote it with a tool.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
indian143 wrote: wrote it with a tool.
Oh I knew that, no one I know will write joins like that. I was interested in whether Jorgen hand coded the changes, he did and deserves your up vote.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Audience on my site is approximately 2-10 users online, database size 170MB, request 5-20/s. Does anyone advise me please, why the tempdb nonstop read / write to HDD for about 2-4MB/sec. Why, or what you need to set or to my tempdb. Thank you.
|
|
|
|
|
The usage of tempdb is highly depend on the queries you run - if you use, for instance, a lot of temporary tables (even local one) it will all go to tempdb...
Please read here to understand the usage of tempdb: http://msdn.microsoft.com/en-us/library/ms190768.aspx[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|