Expanding Hierachy With Multiple Parents
Jul 20, 2005
I have a user assigned multiple roles and a role can be inherited from
multiple parents (see below). How do I answer such questions as "How
many roles does the user belongs to?"
I answered the above questions by using .NET but I think it can be
more efficient by using just SQL. I would appreciate if you can give
me an answer.
Thank you.
CREATE TABLE [dbo].[tb_User] (
[Id] [int] IDENTITY (1, 1) NOT NULL PRIMARY KEY,
[Name] nvarchar(99) NOT NULL UNIQUE,
[Password] nvarchar(99) NOT NULL,
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[tb_Role] (
[Id] [int] IDENTITY (1, 1) NOT NULL PRIMARY KEY,
[Name] nvarchar(99) NOT NULL UNIQUE,
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[tb_User_Role] (
[UserId] [int] NOT NULL ,
[RoleId] [int] NOT NULL,
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_User_Role] WITH NOCHECK ADD
CONSTRAINT [PK_tb_User_Role] PRIMARY KEY CLUSTERED
(
[UserId],
[RoleId]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[tb_Parent_Role] (
[RoleId] [int] NOT NULL ,
[ParentRoleId] [int] NOT NULL ,
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_Parent_Role] WITH NOCHECK ADD
CONSTRAINT [PK_tb_Parent_Role] PRIMARY KEY CLUSTERED
(
[RoleId],
[ParentRoleId]
) ON [PRIMARY]
GO
View 1 Replies
ADVERTISEMENT
Jan 30, 2004
Hi,
I am trying to figure out if this is possible in Oracle or Mysql
Lets say I have 3 tables such that C could have either A or B as its parent.
A
{ id, name}
B
{id, name}
C
{other_id, comment}
Now other_id could be either A.id or B.id. What I want to be able to do is to define a foreign key constraint of the type:
CONSTRAINT FK_C FOREIGN KEY (other_id) REFERENCES A(id) ON DELETE CASCADE,
CONSTRAINT FK_C FOREIGN KEY (other_id) REFERENCES B(id) ON DELETE CASCADE
such that deleting A.id automatically deletes C.other_id where A.id = C.otherid and same for B.id
Ofcourse i am not able to do this. Is there any way that this can be done in Oracle and Mysql?
Thanks a lot,
Priyanka
View 2 Replies
View Related
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
Aug 18, 2015
I have made an SSRS report using the recursive parent functionality to show a hierarchical tree of values. The problem I have is that some children have more than one parent, but because (in order to use the recursive parent nicely) I need to group the results by Id, I only see distinct entries. This means that I only see each child once, even if it "should" appear in multiple locations in the report (under each of its parents).
View 6 Replies
View Related
May 29, 2008
Hi all,
Currently i have this problem and i am not sure how should i implement it.
Let said i have 3 tables. 1 parent table and 2 children tables.
Primary key from parent table is assigned to the children tables. How should i implement it so that a PK from the parent table assigned to child table 1 will not be reassign to child table 2?
Thansk and Regards
Salted Popcorn
View 3 Replies
View Related
May 20, 2008
Hi,
I have a SQL statement that returns a hierachy
it returns ..
-NEWSPAPER
-QUALS
- TIMES
- TELEGRAPH
-MIDS
- DAILY MAIL
- EXPRESS
- EVENING STANDARD
- POPS
- THE SUN
I want the statement to include childnumber column so for newspaper it would count the total number of children below it, so in the above example newspaper would be 9 and for the mids it would equal 3? and pops = 1. does anyone know how i can do this in SQL?
thanks for your help
View 1 Replies
View Related
Jul 23, 2005
Hi,I have a table with filled out below data:+------+-----+|parent|child|+------+-----+|A |B ||B |C ||B |E ||C |D ||E |F ||E |G |+------+-----+So I have to make a query which get all 'parent' values values forgiven child value.For example :-----------------If I have to get all parent values for 'D' child., query must get thisvalues : C, B, A.If I have to get all parent values for 'F' child., query must get thisvalues : E, B, A.If I have to get all parent values for 'C' child., query must get thisvalues : B, A.If I have to get all parent values for 'B' child., query must get thisvalues : A only.-----------------Is it possible to create a query which will covers all above conditionsor not using only sql statement without UDF or stored procedures.Any solutiuons?Sincerely,Rustam Bogubaev
View 3 Replies
View Related
Oct 8, 2015
We have stored some special characters in our database and when we extract as XML Auto, Elements it through error illegal characters during import. I am looking and saw CDATA with Explicit option but don't know how to use it with multi tags like:
<1>
<12>
<23>
<34>
</34>
</23>
</12>
</1>
View 12 Replies
View Related
Sep 29, 2006
Hi!
How can I make a relation that would let me relate an employee to two departments?
There is a table with emloyees and each one works in a department and there is a foreign key relation in the child (employees) table to the parent (departments) table. So can an employee work in two departments? (it's not impossible to imagine, is it?) And how would I retrieve all the employees of a department?
Or in other words, if I were working on some kind of software for my local supermarket and they need to keep track of all bills they ever gave out. I would make this products table and this bills table. Then I would create a foreign key column in the products table and fill it with bill_ids from the bills table and make retrieving bill items a simple getchildrow[](bill_row). Note that this is only an analogy, I need it done this way. How? (using C# express 2005, and SQL express and DataSets)
View 12 Replies
View Related
Jul 20, 2005
Hi,I have a tree structure which is maintained through the use of a pathenumerated column:CREATE TABLE items (item_id NUMERIC NOT NULL,path VARCHAR2(64) NOT NULL);The path is is a colon separated list of ids of the nodes of the tree.So, for example, in this structure:0 -> 1 -> 2 -> 3 -> 4item id 4 would have a path of '0:1:2:3' (0 is the root of allitems, and does not actually exist). Notice that the path does notinclude the item's own id.I would like to select all of the items in a given item's path:SELECT id, path FROM items WHERE id IN (PATH_TO_IDS(path));or maybe:SELECT id, path FROM items WHERE PATH_EQUALS(id, path));or maybe something else altogether. This should return:ITEM_ID PATH------- -------1 02 0:13 0:1:24 0:1:2:3
View 1 Replies
View Related
May 10, 2007
I have created a "parent" table with various columns and added an extra detail row to drop a nested subreport into the table passing parameters into the sub in order to obtain the child subreport. The problem is that the the while I can line up the columns in the sub report with the parent report,
I observe something like this:
parent columns:
a b c d e f
child columns
a b c d e f
The problem is in the last column of the parent "f" it appears stretched out for some reason-about an inch even though can grow is set to false.
Its like the child is forcing the parent's last column to expand yet when i observe the border around the table in the child the "f" is clearly more narrow than the parent's f despite my matching the column widths in the layout exactly the same . In preview mode, the parent's last column is extended width-about an inch more was added. Note I tested it with No data in the child's last column and it still expands the parent column by that inch.
Also note when I dropped the subreport into the parent report I'm merging the cells on the detail row that the subreport fits across columns a, b, c, d, e, f.
So even though the subreports data lines up properly under a, b, c, d, and e; the parent's "f" still expands outward.
Any clues or suggests on what I should consider changing. I'm stumped.
View 1 Replies
View Related
Apr 11, 2007
I need to extract data to send to an external agency in their supplied format. The data is normalised in our system in a one to many relationship. The external agency needs it denormalised.
In our system, the parent p has p_id, p_attribute_1, p_attribute_2, p_attribute_3 and the child has c_id, c_attribute_a, c_attribute_b, c_parent_id_fk
The external agency can only use a delimited file looking like
p_id, p_attribute_1, p_attribute_2, p_attribute_3, c1_attribute_a, c1_attribute_b, c2_attribute_a, c2_attribute_b, ...., cn_attribute_a, cn_attribute_b
where n is the number of children a parent may have. Each parent can have 0 or more children - typically between 1 and 20.
How can I achieve this using SSIS? In the past I have used custom built VB apps with the ADO SHAPE command but this is not ideal as I have to rebuild each time to alter the selection criteria and and VB is not a good SQL tool.
View 4 Replies
View Related
May 30, 2007
I was writing a view that required all of the fields from several large tables. Though I used the * operator in my SELECT statement, SQL Server automatically expanded it to show all of the columns every time I saved the view. Is there a setting somewhere that I can change to make it stop doing that? The query becomes extremely difficult to read because there are so many fields.
View 11 Replies
View Related
Aug 6, 1998
I want to expand a log device and am having a problem. When in Edit Database Device, the `Change Now` button is disabled and the size of the device is shown as a negative number.
View 1 Replies
View Related
Jul 20, 2005
I have a SQL 6.5 database that we parse some data into everyday usingan access program. All this was devises and setup by a programmer thatI can't get in contact with anymore and it has actually run for aboutfive years without a hickup! But just a few days ago our parsingprogram just stops dead before completing and I did get this errormessage."exportaLLdataToSQLifnoerror(): number 3146 Description- odbd- callfailed. [Micorsoft][odbc SQL Server Driver] [sql server] Can'tallocate space for object 'syslogs' in database 'newpdatasql' becausethe 'logsegment' segment is full. If you ran out of space in Syslogs,dump the transaction log. Otherwise, use ALTER DATABASE orsp_extendsegment to increase the size of the segment. (#1105)"I have looked at the database in SQL referred to and I notice that itsays there is 200 MEg allocated for the log size and 250 meg for thedata size and that in both categories there is "0" space available.When I select "EXPAND" on this page it takes me to a screen which hasa graphical presentation with a bar chart showing the available spacein red and the used space in blue on each of what it refers to as'database devices". There are 10 items shown--Temp_DB available space 30 used 30, Newplog 200 available 200 used,NewpDev 250 available 250 used, MSDBlog available 2.00 used 2.00,MSDBData 6 available 6 used, Master 50 available 50 used, Data_log2.00 available 2.00 used, Dale_data 12 available 12 "free space" (this one says free space instead of used?), Contact_log 25 available15 used, Contact_dev 100 available 75 used.So I can see on the first screen that there was 450 meg allocated tothis database called newpdatasql and that all 450 is being used. Andwhen I go to the next screen that shows the devices in this databasethat many of them show that their available space is completely used.The fix is probably to expand the available space for the database. Onthe second graphical screen that shows the bar chart there is anbutton called "expand now" that is greyed out except when you selectthe different devices in a drop-down box at the top of the screen.There are two drop down boxes -- one titled "data devices and onetitled log devices. THe only time the Expand now button is not greyedout is when I select "Dale_Data, "Contact_log", or "Contact_dev". Idid select the "contact_Dev" device clicked on expand and it seemed toI guess expand this device to a fully used level as after I did thisit says that the space available is still 100 meg ( see commentsabove) but now instead of 75 used it says 100 used! Progress or what?I guess I could do this for the other devices as well. One issue forme is whether when the space available for a device is the same as thespace used does this mean that it is at maximum capacity in terms ofdata or only that the space available on the disk for this device iscompletely being made available as potential storage space?Interestingly the original error message mentions "syslogs" and"logsegment" neither are available as devices or are named in thescreens relating to database expansion.Any help would be greatly appreciated.My tollfree number is 866-957 1081.Jeffrey Kilpatrick
View 1 Replies
View Related
Jul 31, 1999
If I have a CustomerDB on ServerA, is it possible to
move/expand the transaction log, .Dat or backup files to
ServerB?
View 2 Replies
View Related
Nov 9, 1999
Newbie SQL question - what logic does SQL Server use to place limits on the extendable size of a database device? I have gigs of room on a partition and I would like to extend a 1GB device to accomodate database growth - but for some reason, Enterprise Manager reads that the max size I can extend the device is only 600MB (when I have 4GB free on the partition). Am I just reading the tool incorrectly?
View 2 Replies
View Related
Jul 9, 2012
I have a table (we'll call it Ranges) of number ranges:
ID Start End
1 12345 12347
2 12355 12359
3 12380 12389
4...
Note: Start and End are text values..What I need is to output these ranges with their corresponding ID:
ID Number
1 12345
1 12346
1 12347
2 12355
2 12356
2...
Note: Number needs to be text.
View 2 Replies
View Related
May 19, 2015
SQL 2012 version
Microsoft SQL Server 2012 - 11.0.5532.0 (X64)
Jul 14 2014 15:00:27
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
management->SQL Error Log-> list of error files are not expanding,Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)A severe error occurred on the current command. The results, if any, should be discarded. (Microsoft SQL Server, Error: 0)
View 8 Replies
View Related
Nov 12, 2007
Okay, so i have a Dual Xeon SQL2k5 Server set up. it's got 4 10k RPM Raptor Drivers (160gb) on it all stripped together. my question is this, i was just doing all kinds of index tuning, and my server didnt have enough disk space to create 2two of the recommended adjustments. i'm curious, if i should just have those two indexes stored on the 1TB Backup array i have? (two 500gb 7200RPM drives)
or should i backup the database, and expand the Raptor Array and then restore the database and create the indexes?
i'm not really worried about down time as long as it doesnt exceed 2 days.
View 3 Replies
View Related
Sep 3, 1999
When running Enterprise Manager from my desktop pc to try and expand a database device I am unable to do so. The size shown is negative, and the max size is the same, with the 'Change Now' box greyed out.
When I log on directly onto the server I can easily expand the db device. There is lots of free space on the server.
Our set up is quite small with four NT workstations and two NT servers with SQL Server 6.5 on them. All these six machines are in the same workgroup. The workstations are on a separate floor to the servers, which are in the computer room. I have a feeling this is a networking issue. Can anyone suggest why this is happening?
View 3 Replies
View Related
Dec 1, 1998
Hi, I have created a 30 gb device_db and named it device_A.Then, I am only allocate 15 gb for my database in that device... My question is if I decided to expand the size of my database in device_A, is there any limitation of how much expansion I can use... for instance can I put 15000 in the Data Device to expand the size of the data base in device_A.... I am not sure if I have to use this in one step, as I explained before or I expand by 500 mb( which will take me 30 times)... any bright ideas
regards
Ali
View 2 Replies
View Related
Sep 18, 2001
Is there any set option with which, the text output from select statement can be changed. A select of any varchar field defaults to 256 characters. If I define a field of varchar(1024), how can I get an output representing all the 1024 characters. Thanks
View 1 Replies
View Related
Oct 10, 2007
Hi friends,
I am doing a matrix report. in this report the matrix can extend to either 1 day or it can extend to 28 days depending upon the range of parameter we give.
example: if we give range of date 7/16/2007 - 7/16/2007 then only 1 column of data will come but if i give the date range as 7/9/2007 - 8/5/2007 then 28 columns will come as 28 days are selected.
i have given the body of the report such that it accomodates all 28 columns. i have few labels that i have to keep on the page header. the width of these textboxs i have given same as the matrix width when it will have 28 columns. in pdf exports the labels in the export comes aligned with the matrix when 28 columns are selected but in html the matrix expands. so it does not look aligned with the labels in the page header.
I hope the above explanation is clear.
can anyone help me on this.
Thanks.
View 4 Replies
View Related
Sep 2, 2005
Microsoft SQL-DMO (ODBC SQLState: 42000) Error 1827: CREATE/ALTER DATABASEfailed.There's more, but it's in italian and I wouldn't know how to translate itproperly.It basically says that the requested size is exceeding some 2048mb limit.I can't see any limitation of this kind in the license. Is there something Iam missing here?Thank you in advance- andrea
View 3 Replies
View Related
Jan 10, 2007
We are currently using an application which uses SQL Server 2005. Both sit on the same box.
This month we're adding another piece of software to our network on a new box which also depends on SQL Server. Since we don't have a directed attached storage device to store (as recommended by Microsoft), we're contemplating installing SQL Server again just for this application. Of course this means that we have to maintain two separate SQL Server databases.
Any thoughts on what we should do?
Thanks
View 1 Replies
View Related
Feb 1, 2005
Pleeeease help? I get an error when expanding the Tables object under linked servers in Enterprise Manager on a MSSQL2000 server.
I have a standard install of the Pervasive.SQL V8 data engine and DemoData db on my local PC. The SQL Server is also on my local PC.
I manage to create the Linked Server using the MSSQL Enterprise Manager. I used the following configuration:
Provider Name: Pervasive.SQL V8 OLE DB Provider
Product Name: Pervasive.SQL V8
Data source: DemoData
Provider string: <blank>
Location: workstation03
Catalog: <blank>
However when I try to expand the tables object under Linked Servers in the Enterprise manager I get the following error.
Error 7311: Could not obtain the schema rowset for the OLE DB provider 'UNKNOWN'. The provider supports the interface, but retuns a failure code when it is used. OLE DB error trace [OLE/DB Provider 'UNKNOWN' IDBSchemaRowset::GetRowset returned 0x80040155 ].
How would I fix this?
Thank you.
View 1 Replies
View Related
Aug 14, 2007
Hello Everyone,
I am trying to expand the multi-valued parameter menu object so I can display the selection list in a more user-friendly format since the text is fairly long. If left at the default setting then I have to scroll to the right to see the complete string(s). For a single-select parameter I can just CAST the string to CHAR(100) and the menu object will expand. However, it seems that this approach is not working for multi-valued parameter menu objects.
Is this a bug in SSRS, and is there another way to accomplish this. Please let me know.
Thank You!!!
View 2 Replies
View Related
Jun 18, 2007
I have a report with a single table, single grouping level, single data set and no sub-reports. It has 3 rows for a grouping header and 3 rows per dataset row of detail. The detail rows are initially hidden and can be expanded by clicking on the header +. Its a fairly standard master-detail report.
Regardless of data size, I get NO page breaks in HTML. I have the Interactive size set to 8.5x11, KeepTogether is set to False, and PageBreakAtEnd is set to False. I would like it to break based on the visible grouping rows.
As it is now, everytime you expand any section, it takes forever to reload for a larger recordset.
I know that "HTML renderer and Preview (which are soft page break renderers) will ignore page breaks of conditionally hidden items and their children.", but how do I get this report to page break?? I've seen a lot of posts on this, but none that seem to have an answer.
View 3 Replies
View Related
Nov 9, 2011
I have a reportviewer on a master page in a VS2008 ASP.NET application. When I originally created the page, I did not use a master page. When I moved the code to a master page, the Toolbar is 6 line long instead of 1. Each of the individual components of the ReportViewer toolbar is placed on it's own line. (i.e Navagation, Print, Zoom, Etc.) The same control worked correctly on it's own page.
View 2 Replies
View Related
Oct 22, 2014
On Visual Studio 2013 with SSDT for SQL Server 2014
I noticed something very strange.
I am viewing the package configuration selected option for a package:
Now, i just click on the - sign and then on the plus sign on the "Properties" branch. And the option is cleared:
The ONLY way i found not to mess everything is just to have ALL the options FULL expanded and THEN to select what i want.
View 4 Replies
View Related
May 30, 2007
Hi,
Is it possible to create Expand/Collapse functionality for the grouped data in Table and Matrix data regions? Essentially, the idea is for the user to be able to see the group/subgroup data if she wishes to by clicking on (+/-) symbols, as is usually the case in Tree View style data grid control in web apps. Any ideas how to accomplish the same in reporting services?
Thanks.
View 1 Replies
View Related
Nov 17, 1998
I have a database in development in SQL Server 6.5 that needs to be occasionally deleted and rebuilt from a script when table structures are changed. I found that when very complex queries were performed, the 2 MB default size of tempdb filled up and returned errors, so I went to the Enterprise Manager to expand tempdb, learned that I had to first expand a device to expand tempdb into, and foolishly chose to expand tempdb into the same device space used by my application, instead of into one of the system databases. Now when I try to delete the device in preparation for its rebuild, the Enterprise Manager responds with an error message saying the device can't be deleted because it contains system tables. Is there any way to get the expanded portion of tempdb out of my application device so that the device can be deleted, without reinstalling SQL Server?
View 1 Replies
View Related