Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How To Add Data Into A PK To FK Relationship?


Hi
I have 2 tables one is called QuickLinks and another called QuickLinkItems
QuickLinks
QuickLinkID<PK>        UserID                 QuickLinkName
--------------------------       -----------                ------------------------
1                         111-111-111-111            QuickLink1

2                        111-111-111-111             QuickLink2
3                        222-222-222-222             QuickLink1
 
QuickLinkItems
QuickLinkID <FK>          CharacterName           CharacterImagePath
---------------------- ------------------------------- ----------------------------------------
 1                                a                            path1
1                                b                            path2
2                               d                              path3
2                               e                              path4
3                               a                              path1
4                               b                             path 2
 
So thats how I see the data will look like in both of these tables the problem however I don't know how to write this into Ado.net code. Like I have made a PK to FK relationship on QuickLinkID(through the relationship builder thing).
 I am just not sure how to I do this. For the sake of an example say you have 5 text boxes 2 text boxes for inserting the character names and 2 text boxes for inserting the CharacterImagePath. Then one for the Name of the QuickLink. So how would this be done? Like if it was one table it would be just some Insert commands.
 Like if this was all one table I would first get the userID from the asp membership table then grab all the values from the textBoxes and insert them where they go to and the QuickLinkID would get filled automatically.
 
The thing that throws me off is the QuickLinkID since it needs to be the same ID as in the QuickLink table. So do I have to first insert some values into the QuickLink table then do a select on it and grab the ID then finally continue with the inserts Into the QuickLinkItems table? Or do I have to join these tables together?
Thanks
 
 




View Complete Forum Thread with Replies

Related Forum Messages:
How Can I Create A One-to-one Relationship In A SQL Server Management Studio Express Relationship Diagram?
How can I create a one-to-one relationship in a SQL Server Management Studio Express Relationship diagram?

For example:
I have 2 tables, tbl1 and tbl2.

tbl1 has the following columns:
id {uniqueidentifier} as PK
name {nvarchar(50)}

tbl2 has the following columns:
id {uniqueidentifier} as PK
name {nvarchar(50)}
tbl1_id {uniqueidentifier} as FK linked to tbl1.id


If I drag and drop the tbl1.id column to tbl2 I end up with a one-to-many relationship. How do I create a one-to-one relationship instead?

mradlmaier

View Replies !
Data Manipulation With One-to-many-to-one Relationship
Is it possible to INSERT, UPDATE, DELETE data in this type of relationship? If so, how in VS2005? Not having issues with SELECT, even without joins.
Thanks

View Replies !
How Can I Populate Data In A One-to-one Relationship
Here is what I have and (somewhat understand).  I’m using Visual Web
Developer 2005 Express Edition and have setup my application to use form authentication
(which automatically creates the ASPNETDB.MDF file with several default tables
and views).  I’m using the CreateUserWizard
which is fine…but I need to collect additional information like (firstname,
lastname, address…and on..).  What I’ve
done.  I’ve created a tabled named
UserProfile and set UserId as the primary key (uniqueidentifier). 
 I then setup a 1-to-1 relationship
between aspnet_Users and UserProfile (which I think is correct).  On my UpdateContactInfo.aspx page (where
users go to update their personal information) I use a hidden label control
(UserValue) to receive the UserId during the page_load event as below:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        UserValue.Text = Membership.GetUser().ProviderUserKey().ToString()    End Sub Now with the UserID available I need to populate the
UserProfile table with the UserId, firstname, lastname, address of the
currently logged in user.   How can I do this and am I on the
right track..?

View Replies !
Database Table Data Modifications With PK/FK Relationship
I have two tables (T1 and T2). In T1 I have a field FT1 that is aprimary key in T2 I have a field FT2 that is a foreign key linked toFT1. These fields have been populated with data. Lets say that in onerow of data I have in T1 under FT1 "my cell" as the data entry,similarly with T2 under FT2 I have 2 rows of data that also have "mycell" as the data entry. What is the best line of action is I wantedto change "my cell" to "my data"?

View Replies !
The Best SQL Query Tool To Visualize Data Relationship
Bay Breeze Software just released SQL Edge 1.4, please refer to http://www.baybreezesoft.com for product details.

SQL Edge is an Eclipse Rich Client application that allows users to execute SQL queries, browse schema information in ER diagrams, and visualize data relationships. With SQL Edge™, users can use only one query to retrieve data in a master table, and then browse data in all related detail tables. Users can also insert, edit, and delete table records in the data grids.

SQL Edge™ has five perspectives. The "Query Perspective" allows users run any SQL queries, while the "Schema Perspective" displays table schema information.

There are two relationship perspectives. The "Relationship Table View" displays data in the master-detail style. The "Relationship Tree View" displays master table records as top-level tree nodes. The nodes can be expanded to reveal any level of related detail records. In addition, clicking any node will display the corresponding data in a detail grid.

The "Model Perspective" displays tables and their relationships in ER diagrams. The tables can be from different databases. Users can define master-detail relationships among these tables, and print or save the diagram for future reference.


The version 1.4 added following features:

(1) Added support for synonyms and CLOB data type.
(2) Added load on demand feature to support large result sets. In query perspective and relationship table view, a selection query will only fetch enough rows to populate the data grids. Users can scroll down the grids to fetch more rows if needed.


The version 1.3 added following features:

(1) Added model perspective to display tables and their relationships in ER diagrams. The tables can be from different databases. Users can define master-detail relationships among these tables, and print or save the diagram for future reference.


The version 1.2 features are:


(1) Support any JDBC compatible databases.

(2) Allow users to specify JDBC drivers at run-time, and provide wizards to help setup JDBC connections. Easy to install, and easy to setup.

(3) SQL editor with syntax highlighting based on currently connected databases.

(4) SQL edtior allows users to execute SQL queries asynchronously. Users can cancel the execution by click the "Cancel" button or just close the SQL Editor.

(5) Schema perspective displays the table schema information, including column definitions, primary key, indexes, and foreign keys.

(6) Relationship table view displays the related data in the master-detail style, with master table data shown in the top grid, and all related detail table data in a list of bottom grids.

(7) Relationship tree view displays the master table records as top-level tree nodes, and the related detail records as child nodes. Click any of these tree nodes will display the corresponding record data in a detail grid.

(8) Allow users to insert, edit, and delete records in the master and detail grids of the relationship table view and relationship tree view.

(9) Allow users to define master-detail relationships even between tables in different databases. This enables the relationship table view and relationship tree view to display data relationships between tables in different databases or without pre-defined foreign keys.

View Replies !
Inserting 1:M Relationship Data Via One Stored Procedure
Hi,

Uses: SQL Server 2000, ASP.NET 1.1;

I've the following tables which has a 1:M relationship within them:

Contact(ContactID, LastName, FirstName, Address, Email, Fax)
ContactTelephone(ContactID, TelephoneNos)

I have a webform made with asp.net, and have given the user to add maximum of 3 telephone nos for a contact (Telephone Nos can be either Mobile or Land phones). So I've used Textbox's in the following way for the appropriate fields:

LastName,
FirstName,
Address,
Fax,
Email,
MobileNo,
PhoneNo1,
PhoneNo2,
PhoneNo3.

Once the submit button is pressed, I need to take all of this values and insert them in the tables via a Single Stored Procedure. I need to know could this be done and How?

Eagerly awaiting a response.

Thanks,

 

View Replies !
SQL Edge - The Best SQL Query Tool To Visualize Data Relationship
Please refer to http://www.baybreezesoft.com for product details.


SQL Edge is an Eclipse Rich Client application that allows users to execute SQL queries, browse schema information in ER diagrams, and visualize data relationships. With SQL Edge™, users can use only one query to retrieve data in a master table, and then browse data in all related detail tables. Users can also insert, edit, and delete table records in the data grids.


SQL Edge™ has five perspectives. The "Query Perspective" allows users run any SQL queries, while the "Schema Perspective" displays table schema information.

There are two relationship perspectives. The "Relationship Table View" displays data in the master-detail style. The "Relationship Tree View" displays master table records as top-level tree nodes. The nodes can be expanded to reveal any level of related detail records. In addition, clicking any node will display the corresponding data in a detail grid.

The "Model Perspective" displays tables and their relationships in ER diagrams. The tables can be from different databases. Users can define master-detail relationships among these tables, and print or save the diagram for future reference.


The major features are:


(1) Support any JDBC compatible databases.

(2) Allow users to specify JDBC drivers at run-time, and provide wizards to help setup JDBC connections. Easy to install, and easy to setup.

(3) SQL editor with syntax highlighting based on currently connected databases.

(4) SQL edtior allows users to execute SQL queries asynchronously. Users can cancel the execution by click the "Cancel" button or just close the SQL Editor.

(5) Schema perspective displays the table schema information, including column definitions, primary key, indexes, and foreign keys.

(6) Relationship table view displays the related data in the master-detail style, with master table data shown in the top grid, and all related detail table data in a list of bottom grids.

(7) Relationship tree view displays the master table records as top-level tree nodes, and the related detail records as child nodes. Click any of these tree nodes will display the corresponding record data in a detail grid.

(8) Allow users to insert, edit, and delete records in the master and detail grids of the relationship table view and relationship tree view.

(9) Allow users to define master-detail relationships even between tables in different databases. This enables the relationship table view and relationship tree view to display data relationships between tables in different databases or without pre-defined foreign keys.

(10) Model perspective to display tables and their relationships in ER diagrams. The tables can be from different databases. Users can define master-detail relationships among these tables, and print or save the diagram for future reference.

View Replies !
SQL Edge - The Best SQL Query Tool To Visualize Data Relationship
For product details, please visit http://www.baybreezesoft.com

If you're developing an object-oriented application that accesses relational databases, SQL Edge is the best SQL query tool for you. To support OO application, the relational schema is often derived from the object model which is pretty deep and tedious to navigate with normal DB tools. SQL Edge is the perfect query tool to navigate the data relationships.

SQL Edge is built upon open source Eclipse Rich client platform. Besides its ease of use, cross platform support and state of the art UI interface, it also enables us to aggressively price the product at $19.99 per copy.

SQL Edge allows users to execute SQL queries, browse schema information in ER diagrams, and visualize data relationships.

With SQL Edge, users can use only one query to retrieve data in a master table, and then browse data in all related detail tables. Users can also insert, edit, and delete table records in the data grids.

SQL Edge has five perspectives. The "Query Perspective" allows users run any SQL queries, while the "Schema Perspective" displays table schema information.

There are two relationship perspectives. The "Relationship Table View" displays data in the master-detail style. The "Relationship Tree View" displays master table records as top-level tree nodes. The nodes can be expanded to reveal any level of related detail records. In addition, clicking any node will display the corresponding data in a detail grid.

The "Model Perspective" displays tables and their relationships in ER diagrams. The tables can be from different databases. Users can define master-detail relationships among these tables, and print or save the diagram for future reference.


The major features are:


(1) Support any JDBC compatible databases.

(2) Allow users to specify JDBC drivers at run-time, and provide wizards to help setup JDBC connections. Easy to install, and easy to setup.

(3) SQL editor with syntax highlighting based on currently connected databases.

(4) SQL edtior allows users to execute SQL queries asynchronously. Users can cancel the execution by click the "Cancel" button or just close the SQL Editor.

(5) Schema perspective displays the table schema information, including column definitions, primary key, indexes, and foreign keys.

(6) Relationship table view displays the related data in the master-detail style, with master table data shown in the top grid, and all related detail table data in a list of bottom grids.

(7) Relationship tree view displays the master table records as top-level tree nodes, and the related detail records as child nodes. Click any of these tree nodes will display the corresponding record data in a detail grid.

(8) Allow users to insert, edit, and delete records in the master and detail grids of the relationship table view and relationship tree view.

(9) Allow users to define master-detail relationships even between tables in different databases. This enables the relationship table view and relationship tree view to display data relationships between tables in different databases or without pre-defined foreign keys.

(10) Model perspective to display tables and their relationships in ER diagrams. The tables can be from different databases. Users can define master-detail relationships among these tables, and print or save the diagram for future reference.

View Replies !
Inserting Data Into Two Tables With Parent-child Relationship
I am trying to insert data into two tables with a SSIS package.  One table has a foreign key relationship to the other table's primary key.  When I try to run the package, the package will just seems to hang up in bids. I have found two ways around the issue but I don't like either approach.  Is there a way to set which table gets insert first?

If I uncheck the check constraints option on the child table, the package will run very quickly but this option alters the child table and basically disables the constraint.  I don't like this option because it is altering the database.

The second approach is to set the commit level on both tables to say 10,000 and make sure that the multicast component has the first output path moved to the parent table.  I don't like this option because I am not sure if the records are backed out if the package should abend after records have been committed.

View Replies !
Import Csv Data To Dbo.Tables Via CREATE TABLE &&amp; BUKL INSERT:How To Designate The Primary-Foreign Keys &&amp; Set Up Relationship?
Hi all,
 
I use the following 3 sets of sql code in SQL Server Management Studio Express (SSMSE) to import the csv data/files to 3 dbo.Tables via CREATE TABLE & BUKL INSERT operations:
 
-- ImportCSVprojects.sql --

USE ChemDatabase

GO

CREATE TABLE Projects

(

ProjectID int,

ProjectName nvarchar(25),

LabName nvarchar(25)

);

BULK INSERT dbo.Projects

FROM 'c:myfileProjects.csv'

WITH

(

FIELDTERMINATOR = ',',

ROWTERMINATOR = ''

)

GO
=======================================
-- ImportCSVsamples.sql --

USE ChemDatabase

GO

CREATE TABLE Samples

(

SampleID int,

SampleName nvarchar(25),

Matrix nvarchar(25),

SampleType nvarchar(25),

ChemGroup nvarchar(25),

ProjectID int

);

BULK INSERT dbo.Samples

FROM 'c:myfileSamples.csv'

WITH

(

FIELDTERMINATOR = ',',

ROWTERMINATOR = ''

)

GO
=========================================
-- ImportCSVtestResult.sql --

USE ChemDatabase

GO

CREATE TABLE TestResults

(

AnalyteID int,

AnalyteName nvarchar(25),

Result decimal(9,3),

UnitForConc nvarchar(25),

SampleID int

);

BULK INSERT dbo.TestResults

FROM 'c:myfileLabTests.csv'

WITH

(

FIELDTERMINATOR = ',',

ROWTERMINATOR = ''

)

GO

========================================
The 3 csv files were successfully imported into the ChemDatabase of my SSMSE. 
 
2 questions to ask:
(1)  How can I designate the Primary and Foreign Keys to these 3 dbo Tables?
      Should I do this "designate" thing after the 3 dbo Tables are done or during the "Importing" period?
(2) How can I set up the relationships among these 3 dbo Tables?
 
Please help and advise.
 
Thanks in advance,
Scott Chang
 
  

View Replies !
Cannot INSERT Data To 3 Tables Linked With Relationship (INSERT Statement Conflicted With The FOREIGN KEY Constraint Error)
Hello
 I have a problem with setting relations properly when inserting data using adonet. Already have searched for a solutions, still not finding a mistake...
Here's the sql management studio diagram :

 and here goes the  code1 DataSet ds = new DataSet();
2
3 SqlDataAdapter myCommand1 = new SqlDataAdapter("select * from SurveyTemplate", myConnection);
4 SqlCommandBuilder cb = new SqlCommandBuilder(myCommand1);
5 myCommand1.FillSchema(ds, SchemaType.Source);
6 DataTable pTable = ds.Tables["Table"];
7 pTable.TableName = "SurveyTemplate";
8 myCommand1.InsertCommand = cb.GetInsertCommand();
9 myCommand1.InsertCommand.Connection = myConnection;
10
11 SqlDataAdapter myCommand2 = new SqlDataAdapter("select * from Question", myConnection);
12 cb = new SqlCommandBuilder(myCommand2);
13 myCommand2.FillSchema(ds, SchemaType.Source);
14 pTable = ds.Tables["Table"];
15 pTable.TableName = "Question";
16 myCommand2.InsertCommand = cb.GetInsertCommand();
17 myCommand2.InsertCommand.Connection = myConnection;
18
19 SqlDataAdapter myCommand3 = new SqlDataAdapter("select * from Possible_Answer", myConnection);
20 cb = new SqlCommandBuilder(myCommand3);
21 myCommand3.FillSchema(ds, SchemaType.Source);
22 pTable = ds.Tables["Table"];
23 pTable.TableName = "Possible_Answer";
24 myCommand3.InsertCommand = cb.GetInsertCommand();
25 myCommand3.InsertCommand.Connection = myConnection;
26
27 ds.Relations.Add(new DataRelation("FK_Question_SurveyTemplate", ds.Tables["SurveyTemplate"].Columns["id"], ds.Tables["Question"].Columns["surveyTemplateID"]));
28 ds.Relations.Add(new DataRelation("FK_Possible_Answer_Question", ds.Tables["Question"].Columns["id"], ds.Tables["Possible_Answer"].Columns["questionID"]));
29
30 DataRow dr = ds.Tables["SurveyTemplate"].NewRow();
31 dr["name"] = o[0];
32 dr["description"] = o[1];
33 dr["active"] = 1;
34 ds.Tables["SurveyTemplate"].Rows.Add(dr);
35
36 DataRow dr1 = ds.Tables["Question"].NewRow();
37 dr1["questionIndex"] = 1;
38 dr1["questionContent"] = "q1";
39 dr1.SetParentRow(dr);
40 ds.Tables["Question"].Rows.Add(dr1);
41
42 DataRow dr2 = ds.Tables["Possible_Answer"].NewRow();
43 dr2["answerIndex"] = 1;
44 dr2["answerContent"] = "a11";
45 dr2.SetParentRow(dr1);
46 ds.Tables["Possible_Answer"].Rows.Add(dr2);
47
48 dr1 = ds.Tables["Question"].NewRow();
49 dr1["questionIndex"] = 2;
50 dr1["questionContent"] = "q2";
51 dr1.SetParentRow(dr);
52 ds.Tables["Question"].Rows.Add(dr1);
53
54 dr2 = ds.Tables["Possible_Answer"].NewRow();
55 dr2["answerIndex"] = 1;
56 dr2["answerContent"] = "a21";
57 dr2.SetParentRow(dr1);
58 ds.Tables["Possible_Answer"].Rows.Add(dr2);
59
60 dr2 = ds.Tables["Possible_Answer"].NewRow();
61 dr2["answerIndex"] = 2;
62 dr2["answerContent"] = "a22";
63 dr2.SetParentRow(dr1);
64 ds.Tables["Possible_Answer"].Rows.Add(dr2);
65
66 myCommand1.Update(ds,"SurveyTemplate");
67 myCommand2.Update(ds, "Question");
68 myCommand3.Update(ds, "Possible_Answer");
69 ds.AcceptChanges();
70

and that causes (at line 67):"The INSERT statement conflicted with the FOREIGN KEY constraint
"FK_Question_SurveyTemplate". The conflict occurred in database
"ankietyzacja", table "dbo.SurveyTemplate", column
'id'.
The statement has been terminated.
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at AnkietyzacjaWebService.Service1.createSurveyTemplate(Object[] o) in J:\PL\PAI\AnkietyzacjaWebService\AnkietyzacjaWebServicece\Service1.asmx.cs:line 397"


Could You please tell me what am I missing here ?
Thanks a lot.
 

View Replies !
How To Set A Relationship Here?
How to create a relation between gf_game and gf_gamegenre here? gf_gamegenre is responsible for the relation between a game and it's genre(s). The relationship between gf_genre and gf_gamegenre worked. (http://img361.imageshack.us/my.php?image=relationzl9.jpg)

 When I try to set a relationshop between gamegenre and game I'm getting this error:
'gf_game' table saved successfully'gf_gamegenre' table- Unable to create relationship 'FK_gf_gamegenre_gf_game'.  The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_gf_gamegenre_gf_game". The conflict occurred in database "gamefactor", table "dbo.gf_game", column 'gameID'.
Thanks for any help!

View Replies !
Need Help With Relationship
I have this situation in my DB:
tblClients, ClientID(pk) 1---M tblDocuments, DocumentID(pk), ClientID(fk), DocumentTypeID M---1 tblDocumentTypes, DocumentTypeID(pk)(this is a lookup table)
If a client is deleted I want to cascade and delete that clients documents from tblDocuments. When I set the relationships delete and update to cascade on tblDocuments it is also set to cascade on the lookup table (tblDocumnetTypes).
Why is this and how do I make it stay the way I want it?
 

View Replies !
Many To One Relationship
Hello
 I have need to write a query that I can pass in a bunch of filter criteria, and return 1 result....it's just ALL of the criteria must be matched and a row returned:
 example:
 Transaction table: id, reference
attribute table: attributeid, attribute
 transactionAttribute: attributeid, transactionid
 Example dat
 Attribute table contains: 1 Red, 2 Blue, 3 Green
Transaction table contains: 1 one, 2 two, 3 three
transactionAttribute contains: (1,1), (1,2), (1,3), (2,3), (3,1)
 
If I pass in Red, Blue, Green - I need to be returned "one" only
If I pass in Red - I need to be returned "three" only
If I pass in Red, Green - nothing should be returned as it doesn't EXACTLY match the filter criteria
 
If anyone's able to help that would be wonderful!
Thanks, Paul

View Replies !
How Can I Set A One-to-one Relationship
How can I set a one-to-one relationship using the Management Studio Express and SQL Server 2005 Express
tblClient, CleintID (PK)
tblProcess, ClientID (FK)

View Replies !
One To One Relationship
I created 2 tables with one to one relationship. if I add a record intable A, how does table B record get created? Does SQL do thisautomatically because it is one to one relationship? or do I need tocreate a trigger? if i need a trigger, how do I get the ID of newrecord to create the same ID in table B?thanks for any help.Joe Klein

View Replies !
One-One Relationship
Hi,Do you guys know what's wrong with a one-to-one relationship?The reason I want to make it like this is that at the very end of the chain,the set of keys is huge. I want to limit the number of columns to be thekey. i.e. the [company] table has 1 column as the key. The [employee]table will have 2 columns as the key.e,g,If I add a [sale] table to the [company]-[employee] relationship, the thirdtablewill have 3 columns as the key -- "company id", "employee id", and "saleid".(e.g.)I have a company with many employees and computers. But instead of classifyall these, I just want to call all these as an entity. A company is anentity. An employee is just another entity. etc.So, instead of a one-to-many:[company]---*[employee]---*[sale]||*[computer]I make it one-to-one.[entity]---*[entity]If I want to know the name and address of the entity "employee", I will havea 1-to-1 table [employee] to look up the information for this employeeentity.[entity]---*[entity]||[company]||[employee]||[computer]||[sale]--[color=blue]> There is no answer.> There has not been an answer.> There will not be an answer.> That IS the answer!> And I am screwed.> Deadline was due yesterday.>> There is no point to life.> THAT IS THE POINT.> And we are screwed.> We will run out of oil soon.[/color]

View Replies !
ER Relationship
For a weak relationship, will 0 and 1 in the ER diagram represent partialand total participations of the 2 entities sets respectively or vice versa.

View Replies !
Many To Many Relationship
hi all,
how to implement the many to many relation ship....
i get stucked it.......
plz help
thanx
sajjad

View Replies !
Why Using One-to-One Relationship
Hey,
I know I'm asking a stupid question but I need to get a clear response please:
why using One-to-One relationship instead of meging the 2 tables in only one?
thanks.

View Replies !
ISA Relationship
Hi,
do you use ISA relationship or do you avoid it? Why?
Could you write me some its benefitsand drowback?
Thanks

View Replies !
One To One Relationship
Can anyone provided insight on how to create a one-to-one relationship between
SQL tables? Every time I try to link two tables that should be one-to-one, the link says one-to-many.
How can I specify one-to-one when SQL Server automatically thinks it is a one-to-many?
Thanks,
Kellie

View Replies !
Fk Relationship
 Hi.
I get this error when i try to create a relationship in a db diagram (sql 2005)
"'tblActivedir' table saved successfully
'tblClient' table
- Unable to create relationship 'FK_tblClient_tblActivedir1'.
Introducing FOREIGN KEY constraint 'FK_tblClient_tblActivedir1' on table 'tblClient' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint. See previous errors."


What i have is 2 tables.
1 named client
1 named activedir

In the client table the columns i want to bind with activedirtable are FR1 and DC1
I want to bind them in the ID of the activedir table (both, in different fk relationships) so that they get the id of activedir.
Fr1 has an fk relationship with activedir (pk is activedir' id)
and DC1 exactly the same in another fk.
So i want both columns to comunicate with activedir.
If p.e. activedir has 3 elements (a,b,c) when i delete element a then werever FR1 or DC1 have this element(binded to it's id) then the element will also be deleted (id of the element) from both FR1 and DC1
I don't want to set Delete and Update action to none because i want the element changed or deleted from activedir, to do the same on Fr1 or DC1 or both.
Any help?
Thanks.

View Replies !
ERD 1:1 Relationship
I am trying to create a 1:1 relationship, but not primary key to primary key. In table 1 I have a uniqueidentifier as a primary key. In table 2 I have an int as the primary key and a column that takes the uniqueidentifier from table 1. Everytime I drag and drop the relationship line and link table 1 to table 2 it creates a 1:N relationship: ie. tbl1.primarykey links to tbl2.column2. So I'm not linking primary key to primary key however I still want a 1:1 relationship.

 

How do I do that?

Thanks in advance.

View Replies !
One-To-Many Relationship
SQLServer 2005 - I have two tables.  One has a field defined as a Primary Unique Key.  The other table has the same field, but the Index is defined as non-Unique, non-clustered.  There is no primary key defined on the second table.  I want to set up a one-to-many relationship between the two, but am not allowed.
 
This should be simple.  What am I doing incorrectly?

View Replies !
Relationship Between A AND ( B OR C )
I have a fact table with 2 fields : "Dim Code 1" and "Dim Code 2" that I want to link with a Dim table.
I don't want to create two dimensions Dim1 and Dim2 but only one dimension with something like :





Code Snippet


      Dim.Code=Fact.DimCode1 OR Dim.Code=Fact.DimCode2



Is it possible to do this ?


Thanks in advance

View Replies !
ERD Relationship
hi, I've draw the ERD for my database in management studio express but I have a question regarding the relationship between tables. How can I define the cardinality of the relationship between two tables? by default in managemet studio is it the relationship is only one-to-many relationship?

View Replies !
Relationship
Hi.
(Sorry if i am not posting this in the right forum)

well i am learning to create a small software and have come up with four tables which are as follows;


Client
date
<!--[if !vml]--><!--[endif]-->client_id
name
address
contact_num
 
Smoking
smoking_id
client_id
meas_arm
meas_neck
meas_shoulder
Color_code
description
Trousers
trousers_id
client_id
meas_leg
meas_hips
meas_waist
color_code
description
 
Shirt
shirt_id
client_id
meas_arm
meas_neck
meas_shoulder
color_code
description
My question
Is it possible to have a relationship linking one single table to other several one.
For example i wanted to relate the field client_id from table client which is the primary to tables shirt,trousers and smoking with the client_id field which is the foreign key ?

thanks 

View Replies !
Key Relationship
This is the message that i get when trying to assign keys when creating diagrams in visual express:

 

'tbh_Polls' table saved successfully
'tbh_PollOptions' table
- Unable to create relationship 'FK_tbh_PollOptions_tbh_Polls'. 
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_tbh_PollOptions_tbh_Polls". The conflict occurred in database "C:USERSSTICKERDOCUMENTSMY WEB SITESPERCSHARPAPP_DATAASPNETDB.MDF", table "dbo.tbh_Polls", column 'PollID'.

 

PollID is my primary key in tbh_Polls

And PollID is in tbh_PollOptions table

 

No matter what I do, I get this message, I'm Lost!

Help plz.

Thanks

 

View Replies !
One To One Relationship
How do I create a one to one relationship in a SQL2005 Express database? The foreign key needs to be the same as the primary key so it can't just increment to the next number.

View Replies !
Get Relationship Via SQL
Hey,

is it possible to get the relationship of a table via sql? Like I need to know which relations the table t has. Is that possible?

Thanks

View Replies !
FK - PK Relationship Problems
HiI have a FK to PK relationship problem. I have 2 tablesQuickLinks<PK>QuickLinkItems<FK>So what I had this is I made a relationship. I put in the relationship options this. I turned off "enforce FK contraint" and I put for the delete rule "cascade". So I turned off the FK contraint since I don't think with it on the cascade delete would work.  So now I tried it out. I launched my website and tried to delete something but no cascading happened. I then went to MS SQL and added some new values in and tried to delete it there(by clicking on the column and hitting delete). No cascadeing happened. What am I doing wrong? 

View Replies !
What Relationship To Use Between These Two Table?
Hi I have two tables:
1.) Operator-OperatorID{PK, int, not null}-OperatorName{varchar(100), not null}-Enabled{bit, not null}-PasswordChange{bit, not null}-BirthDate{datetime, not null}
2.) Password-PasswordID{PK, int, not null}-Password{varchar(50), not null}-ExpirationDate{datetime, not null}
I'm not sure how to design and layout these two tables. The layout of these two tables is completely flexible as the application has not been deployed. I'm open to any good suggestions.
For each Operator I want to stored up to 3 previous passwords plus their current password. The password change field is so that if the operator's password expires or gets reset, they will be forced to enter a new password. This is a simple internal company application, so password encrypting is not necessary. The ExpirationDate indicates the date that the password will expire.

Hope to hear from someone soon! Thank you!

View Replies !
Simple DB Relationship
hi there, after a lot of fussing about i found it would be a lot easier to use an SQLDS and a gridview to display my data rather than code it. However i cant for the life of me work out how to replace some of the numbers (IDs) with their accompanying names. so i have a QTY which is an INT and a Location1 which is an INT in tbl_stock_location and in tbl_locations i have the appropiate 1 = shop etc this is what i came up with for my string
SELECT tbl_stock_part_multi_location.stock_part_multi_location_ID, tbl_stock_part_multi_location.stock_ID, tbl_stock_part_multi_location.Description, tbl_stock_part_multi_location.Qty1, tbl_stock_part_multi_location.Location1, tbl_stock_part_multi_location.Qty2, tbl_stock_part_multi_location.Location2, tbl_stock_part_multi_location.Qty3, tbl_stock_part_multi_location.Location3, tbl_stock_part_multi_location.Qty4, tbl_stock_part_multi_location.Location4, tbl_stock_part_multi_location.Qty5, tbl_stock_part_multi_location.Location5 FROM tbl_stock_part_multi_location INNER JOIN tbl_location ON tbl_stock_part_multi_location.Location1 = tbl_location.Location_ID AND tbl_stock_part_multi_location.Location2 = tbl_location.Location_ID AND tbl_stock_part_multi_location.Location3 = tbl_location.Location_ID AND tbl_stock_part_multi_location.Location4 = tbl_location.Location_ID AND tbl_stock_part_multi_location.Location5 = tbl_location.Location_ID WHERE (tbl_stock_part_multi_location.stock_ID = @stock_ID)"
 
I used the query builder for this but it just dosnt seem to work and throws an error at me. Any help would be great!

View Replies !
Join One To Many Relationship
 hi all geeks,

I have a problem regarding joins.

I have 2 tables,

Customer ( Customer_code, Agent1, Agent2, Agent3)

Agent( Agent_Code, Agent_name) 



 and data is like this:




Customer_code
Agent1
Agent2
Agent3



1
1
2
3



2
2
3
4



3
1
4
3

Agent Table


Agent_Code
Agent_name



1
X



2
Y


3
Z


4
P

5
Q


Now I want to retrieve all customer_code with their corresponding agent names, like 1   X   Y   Z2    Y    Z    P3    X    P    Z, any suggestions please,thanks a lot.  

View Replies !
Relationship Diagram
Hi there, I just set up my AppData and i'm trying to connect the Membership to a tbl_Profile that i created.I notice there's an application_id and a user_id which are uniqueidentifiers.  I've been trying create a relationship to tbl_Profile's user_id column but it won't let me saying it's not compatible. Am i suppose to set tbl_Profile's user_id column to int or uniqueidentifier? I've tried both and it won't let me... THanks! 

View Replies !
Help With Foreign Key Relationship
When I try to insert a record on my DB (SQL 2005 Express) I get a constraint error. This is my table setup which has been simplified to expose the problem I have:
Categories TABLEint CatId PKvarchar CatName    :
Items TABLEint ItemId PKvarchar ItemName      :
X_Items_Categoriesint CatIdint ItemId
So  basically I have a one-to-many relationship between Items and Categories, in other words each item is associated to one or more categories and this association is done via the X_Items_Categories cross table. On this cross table I set two constraints:


The CatId of each entry in the cross table (X_Items_Categories) must exist in the Category table, and

View Replies !
Table Relationship
Hello, I created some SQL 2005 tables using Microsoft SQL Server Management Studio. I need to get the script code of those tables. I was able to do that by right clicking over each table. But how can I get the code for the relationships between the tables? Can't I create relationships between two tables by using T-SQL? Thanks, Miguel

View Replies !
Optional Relationship
Hi, how can i make optional relationship?
for example: In table A, there is column 1, column 2, column3. In table B, there is column 4, column 5 and column 6.
 column 1 and column 2 are primary keys for table A and table B. The relationships between table A and table B are column 2 and column 5; column3 and column 6. but optional (ie. when data exists in column 2, then column3 is null)
 how can i set the relationship? because one of the columns data is null each time, error always occurs.

View Replies !
Relationship To UserId
Hi there everyone, this is my first post so go easy on me :)
Basically I am trying to get my database to copy the value in the UserId (unique identifier field) from the aspnet_Users table to a foreign key UserId in a table called userclassset. I have made this field the same datatype and created a relationship between the two. Unfortunately, when I add a user using the ASP.Net configuration tool it does not automatically copy this value into my own custom table. I have noticed it is however automatically copied into the aspnet_Membership table. Any pointers on how to solve this would be great!
 Thanks :)

View Replies !
Relationship Diagram
Hi:
I'm using SQL SERVER 2005 EXPRESS
How Can I view the relationship diagram of a database on Management Studio?
Thanks!!

View Replies !
Foreign Key In One To Many Relationship
Hi
I have a one to many relationship between two MS SQL tables.
When inserting a record in the master table (primary key is autoinc) how can I get this value for setting in the foreign key details table?
TIA

View Replies !
Trying To Create A Relationship
Here is the error I am getting'role' table saved successfully'users' table- Unable to create relationship 'FK_users_role'.  ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]ALTER TABLE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_users_role'. The conflict occurred in database 'raintranet', table 'role', column 'role_id'.table rolerole_id intname varchar 50table usersusers_id introle_id inTrying to get table.role_id to be related to role.role_idAny help would be appreciated

View Replies !
Delete Relationship?
How do I delete a relationship between tables in SQL Server 7.0?I previously had a relationship between two tables, but I renamed the fieldand table of one of the tables and the old relationship still points to theold field name and table. How do I remove the defunct relationship?It doesn't show in my diagram because the old table no longer exists (wellit does but it's been renamed).

View Replies !
Strange FK Relationship - How, And Is It Right?
Hello all,I have a scenario in which there are three tables, A, B and C. A and Bhave PK columns, both are of the same type. C has a FK column, of thesame type as the PK columns of A and B, but the values in it should beeither in the PK column of A or in the PK column of B...I figured out I could do this by creating a check constraint along witha user defined function to make sure the master table (either A or B)has a corresponding row before a row is inserted or updated into C. ButI don't know how to handle deletions from A and B: how to make sure thecorresponding row in C is deleted first. Any help would be greatlyappreciated. Thanks.Now the more important question: C has 6 columns, and all these columnsare common to both A and B. That is, the common columns of A and B havebeen moved to a new table C. Apart from this, there is no purpose ormeaning to having the table C; if it were not for C, A and B would'vehad 6 additional columns. I know such factoring is common in the OOworld, but is it right in the RDBMS world? What else should've beendone? Any thoughts/suggestions? Thanks a lot in advance.- Ramesh

View Replies !
Foreign Key Relationship
HiIm a sql newbie , and have created two tables with a foreign keyrelationship.How do i insert into these tables. If i insert into the primary tablewill the foreign key field in the second table be automaticly updatedby ms sql server ?

View Replies !
Retrieve First Row Only In Many-to-many Relationship
I have a db with three tables - books, sections, and a joining table.The normal way of getting a many to many relationship (i.e. one bookmay belong to many sections, and one section may contain many books)I want to extract the data with a single row for each book so that Ionly retrieve the first section description for any book. (e.g. title,author, section, description)Structure as follows:tbl_bookbook_id, title, author, description etc...tbl_sectionsection_id, section_desctbl_book_sectionbook_id, section_idDBA is away and I can't figure this out at all...any help gratefullyreceived.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved