Very Tricky Hierarchy For Dimesion From Relational Database
May 22, 2008
I need to create a dimension with a hierchy derived from 3 other dimenions where one of the dimensions contains a recursive hierarchy.
eg:
In my RDBMS I have; a table "Entities" which contextualises geographic locations and (typical columns include and id and a description with values for: ID1=United Kingdon, ID2=France, ID3=Norway, ID4=Finland, ID5=Europe, ID6=Scandinavia, etc.), another table "Entity_Type" which contextualises the values held in "Entities" (Typical olumns; ID1=Continent, ID2=Country) and a table, "Geo_Code" which codifies the values from both "Entities" and "Entity_type". They act more or less like 2 dimensions ("Entities", Entity_Type) and a fact table ("GEO_Code").
The third table has a recursive hierarchy in that it references it's own ID again in column "Entity Reference".
The first table is Entities, the second is Entity_Type and the third is the one that references both.
id
description
01
England
02
Norway
03
Europe
04
Scandinavia
id
description
01
Continent
02
Country
id
entity
Entity_Type
entity Reference
01
03
01
NULL
02
04
01
NULL
03
02
02
02
04
01
02
01
From the last table "GEO_CODE" we can determine the following:
01. Europe is a continent
02. Scandinavia is a continent
03. Norway is a Country that is in Scandinavia (Entity Reference recursive referencing ID 02 of the same table where the Entity is 04).
04. England is a Country that is Europe (Entity Reference recursive referencing ID 01 of the same table where the Entity is 03).
How do I create a new dimension using Visual Studio in Analysis Services where the Hierarchy is reflected?
So far, I have managed to depict 2 Hierarchies: where a dimenion depicts Entity (Countinent/Country) as level 1 and the value of the corresponding entity (Europe, ENgland, Norway, Scandinavia) in level 2 but how do I get to the last bit where the Entity Reference references the location of the Country or Continent???
Hi all, I am trying to create a diagram for our database, during the creating, I create some of the relationships which were not there(basically our original database is not relational database, that's why I am doing it) So sometimes I have to chage data type in order to create a relationship for the coloumns in different tables. i.e. change char(16) to varchar(7) (I checked the field that make sure all the data in this field is <= 7 characters)
But when I saved the diagram, there is an error message that state: Errors were encountered during the save process. Some of your database objects are not saved on your diagram.
'agent' table saved successfully 'VisitUSA' table - Unable to create relationship 'FK_VisitUSA_agent'. ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]ALTER TABLE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_VisitUSA_agent'. The conflict occurred in database 'CMC', table 'agent', column 'AgentCode'.
What does that mean? is it caused by some of the agentcode data in VisitUSA table which is not in agent table? Thanks! Betty
does it build has values for inbound value and compare it to a stored hash value to determine if a change exists?
Are each of the attributes chequed one by one for a change?
Does a lookup occur at somepoint on the target table. i.e If I have a 16m row table will it lookup and cache all 16m rows or is it smart enough to only lookup and cache the rows that it expects based on a PK value
Basically what I'm asking is for a technical explanation as to how it works and how to tune it or the underlying data to make it perform well.
Table1 contains ID,Name Table2 contains ID,Marks,Foreign Key ie Primary key of the table Table1.
Give me an information how to create these two tables in SQLServer (I know how to create a table but i don't know how to create a table which includes Foreign Key.)
Then using Dataset i want to display the records as Name,Marks which are stored in two tables.
I have studied that in ADO Join query and record set object is used but it gives a problems and it is not good when we want to transfer the data between two applications or pages but dataset solves all those problems.
Hi,I have a very simple question.In what cases are relational databases necessary?Are they really necessary in cases where only asingle type of query is to be performed based on one uniquefield or can we just put all fields together in a single databaseand just access them through that unique field?
What is the best approach for storing hierarchical data in a database? For example, if I need to store a tree menu system, how would I do that allowing for the most normalization within the database, using the least number of queries/resources when pulling the data out, and using the least amount of overhead both in storage and retrival?
Dear friendsI am conducting a survey on Relational Database usage and would likeyour help. The study is part of my MBA Dissertation.Could you kindly spare 5 minutes to take part in this survey?http://FreeOnlineSurveys.com/rendersurvey.asp?id=120816ThanksRajeev
I have a database has the following linklist structure. A, B, B1, B2 and B3 are records. A is a group and the others are group members *************************************** A.PointertoB B.ForwardPointertoB1 B1.ForwardPointertoB2 B2.ForwardPointertoB3 B3.end *************************************** I want to convert them to relational database structure so I need to find following pointers
B.PointertoA B1.PointertoA B2.PointertoA
Can I use sql to find the pointers? Thanks in advance.
I need to restore a DB that was backed up prior to the installation of SP3 on this SQL Server. To make a long story short, DB was backed up on SP1, I want to restore it to the same device that is now running SP3. Is that possible? Can anyone think of any issues or have some prior knowledge that may help me... Thanks!!!
Can this be done in ASP.Net, as it stands my database views in my ASP.Net application are just standard Unlike the view in MS Access which shows the collapsable linked data below the data (from a different table)
Sharepoint is a pretty darn dynamic service and that got me thinking of how databases are created. Just wondering out loud, surely someone has thought of creating databases in such a manner, but I don't know if it's a thought that has been struck down.
It would look something like this: Single Table ID uniqueidentifier PK ParentID uniqueidentifier FK to ID Name nvarchar(MAX)
Value nvarchar(MAX)
In this manner, you would create your database "columns" as needed in the data-layer.
If that is too strict, (every datatype would be encoded to base64), you could create a value option for basically every data type. EG. nvarchar(max), nvarbinary(max).... and add another field that describes the data-type to be used for that "column" ID uniqueidentifier PK ParentID uniqueidentifier FK to ID Name nvarchar(MAX) DataType nvarchar(50) //constrained to allowable datatypes MaxLen nvarchar(31) //ahh, what the hey, let's add this for sniggles. ValueNvarchar nvarchar(MAX) nullable
ValueNvarbin nvarbinary(MAX) nullable
....
Now, to allow the "values" for those "columns", you may be able to still use the single-table approach, but it may be better to have an extra table for that (probably even a different partition and drive).
Things to consider, indexing..... In development, the data-layer would handle the creation/reading of table columns. The business-layer, which could be many for different parts of a company, would make it's requests to the DL. It may need a username, and the DL would either just create it, or suggest an already existing username column. The path to that username may not be where a particular biz element wants it, so they will ask the DL create another under a diff path.
The business-layer is probably the most important reason for wanting a single dynamic table.
In the end, the relation structure could be like: Human //dir, no value, no parent (root) FirstName //value - text LastName //value - text Parent1 //value - Me Id Sibling1 //value - Me Id SiblingN //value - Me Id
School //dir, no val ParentId //value - Id (perhaps category would be Building) Name //value - text
The sibling N would be an example of how a table may need to be dynamic. A positive of the single-table approach is no limitation on number of "columns". Another is the ease to move a hierarchical structure if needed. School may want to be University instead of just "school" and be placed as a child of "school".
As people say, Microsoft was the first major database vendor to include data mining features in a relational database. What dose this exactly mean? Thanks a lot for any guidance.
hello, I am beginner for asp.net and sql server. I used Sql server manegement studio full version and I exported my aspnetdb which was created by VS2005 to my host sql server. I have a question: relational tables are not relational no longer. I noticed that when I created database diagram. what is wrong by exporting? thanks for your helps...
Hello:In my SQL Server databases I have complex related tables and views.There is any tool which allow you to see (print) this complex hierarchy ofviews and tables as hierarchical tree?Thanks,GB
Hello, I have four diffrent tabels: bo_ Class, bo_Competition, bo_Result, bo_Licence And list all Licence where bo_Class.classRankingNbr >0
ResultLicNbr FirstName SurName ClassName ResultPlace ClassRankingNbr ClassRankingFemaleMale ------------ --------- --------------- ------------- ----------- --------------- ---------- M70891DEN03 Dennis Vrabac U23 SM 2007 - Herrar 1 1 H M050887PON01 Pontus Svensson U23 SM 2007 - Herrar 2 1 H M181188MAR01 Marcus Edlund U23 SM 2007 - Herrar 3 1 H M190291JOH01 Johan Helldén U23 SM 2007 - Herrar 4 1 H M180360GER01 Gert Lindholm Herrar klass A 1 2 H M041062MIC01 Micael Hamberg Herrar klass A 2 2 H K191286SOP01 Sophia Bergvall U23 SM 2007- Damer 1 1 D K030889REB01 Rebecka Larsen U23 SM 2007- Damer 2 1 D K050785CAR01 Carin Johansson U23 SM 2007- Damer 3 1 D
If bo_Class.ClassRowNbr for an Class is 1 get out place 1 from that competition, and if an ClassRowNbr is 2 get out top2 from that competition. And so on.
From that list i want an SubQuery list where all licens order by where bo_Result.ResultPlace = bo_Class.ClassRowNbr.
In text form:
ResultLicNbr FirstName SurName ClassName ResultPlace ClassRankingNbr ClassRankingFemaleMale ------------ --------- --------------- ------------- ----------- --------------- ---------------------- M170891DEN03 Dennis Vrabac U23 SM 2007 - Herrar 1 1 H M180360GER01 Gert Lindholm Herrar klass A 1 2 H M041062MIC01 Micael Hamberg Herrar klass A 2 2 H K191286SOP01 Sophia Bergvall U23 SM 2007- Damer 1 1 D K030889REB01 Rebecka Larsen U23 SM 2007- Damer 2 1 D K180793LIN01 Linnéa Hamberg Damer Klass A 1 1 D
SELECT m.Namn + ' ' + m.ENamn AS Spelare, SUM(r.Serier) AS Ser, SUM(r.Poang) AS Po, ROUND(SUM(r.Resultat) / SUM(r.Serier * 1.0), 2, 1)AS Snitt, ROUND(SUM(r.Poang * 1.0) / SUM(r.Serier), 2) AS [P Snitt], ROUND(SUM(r.Miss * 1.0 / r.Serier), 2, 1) AS Miss, SUM(r.Miss) AS [Sa Miss], MAX(r.Resultat) AS Bästa, MIN(r.Resultat) AS Sämsta FROM Resultat r INNER JOIN Medlemmar m ON r.Spelare = m.ID WHERE (r.Omgang IN (SELECT DISTINCT TOP 3 Omgang FROM Resultat ORDER BY Omgang DESC)) GROUP BY m.Namn + ' ' + m.ENamn ORDER BY 4 DESC
What i want to do is sort out Min(r.Resultat) where serier is mor than 3, Not WHERE (r.Resultat) >3. More like in Access "Min(IIf(r.serier=4,r.resultat,Null)) AS [Sämsta]" But that i cant do in SQL
Have also tryed with "WHERE (SELECT MIN(r.Serier) FROM Resultat Resultat r INNER JOIN medlemmar m ON r.Spelare = m.ID" Get lowest result same on all players.
Hello allI've got this tricky situation that I would like to solve in SQL, butdon't know how to do. This is the table:Id = 3, VId = 2, Time1 = 10:00, Time2 = 14:00Id = 4, VId = 2, Time1 = 16:00, Time2 = 17:00Id = 5, VId = 2, Time1 = 18:00, Time2 = 19:00Id = 6, VId = 2, Time1 = 20:00, Time2 = 21:00Id = 7, VId = 3, Time1 = 11:00, Time2 = 13:00Id = 8, VId = 3, Time1 = 15:00, Time2 = 16:00Id = 9, VId = 3, Time1 = 18:00, Time2 = 20:00GetRows @Time='15:30' will return row with Id=4GetRows @Time='16:30' will return row with Id=4 and row=9Logic behind this:Return row n where Time2 of Id=(n-1) < @Time < Time 1 of Id=(n) and sameVId.Ie. if @Time = '15:30' then Time2 of Id = 3 is lower than @Time, andTime1 of Id = 4 is higher than @Time => return row with Id = 4.This got a bit messy but if someone could decipher this and possiblygive an answer I'd be very glad.regardsJohnny
I have an integer in the database that was saved in reverse byte order (BigEndian). Due to some backward compatibility issues (long story) I can't just convert the number to the normal format and save it that way in the database. Instead, when I read the number in my program, I just reverse its bytes and display the proper value, and translate the number back when it has to be saved back to the database.
Now, the problem is that there are some views that pull this numbers directly from the database and display it.
My question is: can this number be converted from BigEndian to LittleEndian similarly to how I do in my program using T-SQL?
I have a membership database and a profile database with a userid column in both. The foreign key is in the profile database where i want a persons profile details to go like location,occupation and what not. How do I make it so when a new user registers a userId is created in the profile database that matched the userid in the membership database so i can query out profile details based on a registered members userid?
Hi all! I am working on a piece of SQL at the moment and I'm getting a little confused. I have 3 tables: Items, Attributes and a table linking them. I have 5 attributes and an item can have any of the 5 attributes. So my linking table holds the ItemID and the AttributeID and there can be 1-5 entries for each Item. A user can search for items based on Attributes; so they can tick 5 checkboxes that represent the 5 Attributes. So I need to build a query based on their choices. At the moment I'm using:Select * FROM ItemsINNER JOIN linking on Link_ItemID = Item_IDWHERE Link_AttributeID IN (10, 13, 17)But this brings out the Item that have either AttributeID of 10 or 13 or 17 whereas I need it to pull out ONLY items that have a AttributeID of 10 AND 13 AND 17.Can anyone help with this query? Sorry if this is badly worded. The solutions is prolly something really simple I have overlooked... :SI've also tried:Select * FROM ItemsINNER JOIN linking on Link_ItemID = Item_IDWHERE Link_AttributeID = 10 AND AttributeID = 13 etcBut obviously that won't work! :s
what is the difference in making relational databases in SQL vs. Access? Do you need to make them if you will be using ColdFusion? What do the other fields in minor tables need to be in order to connect them to a major table when it will all be based on a number that is in the major table? i'm kind of confused on this issue...Thanks!
I created the third table to hold the employeerenewal dates, I did this because I cant have repeating vaules in the primary table. I am just making sure that my course of action is the correct one. The purpose of the Employeerenewals is to give the users an indication that a certain renewal has been processed, because in the past there was several hundred that were not processed. The problem was that the users had no way of knowing this. What I was thinking was having the primary table calculate a renewal date based off the finalsuit and show the results in the Employeerenewals with a yes of no drop down. Now the yes or no drop down box will be give the users their red flag if the renewals have been processed or not.
Hi I am developing a website current and i have a database that seems to be growing very rapidly.. I would like to ask if anyone knows of any good tutorials/examples on relational databases? Also does anyone know of any good database design tutorials/examples?
If it helps i am using Microsoft Visual Web Developer
My question: How to have an unknown number of authors returned for a list of books, with the multiple authors being returned on the SAME row as each book
My table structure:
Table A - Books ------------------- BookID | BookName ------------------- 1 | Book One
Hi,This question has been bothering me for some time. A lot of peopleseem to "think" XML is the king of data problems, and I've heard thatnext version of SQL Server is going to have a strong XML flavor,meantime, I seem to get the impression that a large number ofhard-core relational model gurus do not seem to be that impressed withXML (technical value of this extra layer seems to be limited whilebusiness value might be substantial for instance, more software work,more disk space requirement etc. etc.). What's your take on this?Generality or specifics, all welcome. One specific question is, howcan XML supplement relational model?Thanks.
I have a few questions for you guys. I have a client application that can be offline or online. While offline, records can be added and need to be later synced to production.
I will use rda to pull the table down, and this is working fine. Now what if I have multiple tables where I want a foreign key relationship?
With rda I can only pull down one table at a time from everything I've read. Now say create a constraint after pulling the two or more tables down. While in offline mode I create a new record on two seperate tables with foreign key/primary key relationship.
When I do the push to the server will it automatically update the foreign key reference (locally) to the right one on the production server? Or will I get a duplicate primary key error? On the production server the primary key will be different because of the identity. This is very important because I will have multiple clients.
I have a LastName field which holds this dataLastNameJohnson|VasquesAdams|Fox|JohnsonVasques|Smith Now let’s say I have a SELECT Stored Procedure which takes 1 parameter @LastName.The @LastName can be something like this: “Fox|Smith�.I would like to have my SP to return me all of the records where LastName field have any of those names (Fox or Smith).In this example it will be the last two records: Adams|Fox|Johnson and Vasques|Smith . Thank you.
This is more of a SQL question than a .NET question, but if you could indulge me, I'd appreciate it. I have a table that has 2 columns of particular interest for the purposes of this question. One is a foreign key to another table (int), the other is a name (varchar(50). I want to sort the results set in a specific way. I want to sort it in such a way that all entries that have the foreign key = 0 come first (sorted ASC by name) then I'd like all the other results with foreign key column > 0 to be sorted ASC by name. I was trying to be cute and tried an order by statement like this: "ORDER BY (foreignKey > 0), name" but it's a syntax error (as I initially thought it might be). I know I could probably do a stored procedure that will create a temporary table and I could insert a new column to help put these in order, and I also know I could put all the results into an array, then sort the array in code, but I was just wondering if there was a simpler, slicker way (tricky SQL query perhaps).