Many To One Relation - Is It A Good Idea?

Jun 11, 2008

Hi

I have about six different entities that can have zero or more note entities associated with them. The easy way to do this is obviously to have a different "note" table for each of the entities i.e. WorkItemNote, CustomerNote etc.. But I would much rather have a single "note" table since they would all be identical, so I came up with this design:


CREATE TABLE WorkItem
(
WorkItemGuid uniqueidentifier PRIMARY KEY DEFAULT (newid()),
-- rest of table declaration removed for bravity
)

CREATE TABLE Customer
(
CustomerGuid uniqueidentifier PRIMARY KEY DEFAULT (newid()),
-- rest of table declaration removed for bravity
)

CREATE TABLE Note
(
NoteId int IDENTITY(1,1) NOT NULL PRIMARY KEY,
ReferenceGuid uniqueidentifier NOT NULL,
Text ntext NOT NULL,
-- rest of table declaration removed for bravity
)


This way I can get notes associated with a given entity, either Customer or WorkItem, by just selecting from the Note table with its WorkItemGuid or CustomerGuid.

My question is: Is this the best approach to what I am trying to accomplish?

(ps: Apologies if "many to one" is not the right terminology)

Regards, Egil.

View 12 Replies


ADVERTISEMENT

Need Good Idea

Jul 23, 2005

Hi guysWe have a following problem. For security reasons in each table in ourDB we have addition field which is calculated as hash value of allcolumns in particular row.Every time when some field in particular row is changed we create andcall select query from our application to obtain all fields for thisrow and then re-calculate and update the hash value again.Obviously such approach is very ineffective, the alternative is tocreate trigger on update event and then execute stored procedure whichwill re-calculate and update the hash value. The problem with thisapproach is that end user could then change the date in the tables andthen run this store procedure to adjust hash value.We are looking for some solution that could speed up the hash valueupdating without allowing authorized user to do itThanks in advance,Leon

View 6 Replies View Related

Can Anyone Explain To Me Why This Is Not A Good Idea

Jan 28, 2008

I have a complex select statement that is used in several stored procedures. I decided that instead of having x number of T-SQL scripts with the same exact select statement that I would to put this query into a view and then do a select * from View.  Recently an instructor told me that this was a bad idea and that anyone who uses a select * from anything should be fired.  When I asked for his reasoning his response was to say the least abnoxious.  I can understand why a Select * from Table might be a bad idea as the table definition can change, but the chances of a view changing seems much less likely.
Is a view a good idea in this case?  Is the Select * from View really a bad idea?
 Thanks
 
 

View 6 Replies View Related

AUTO_UPDATE_STATISTICS A Good Idea?

May 20, 2003

Can anyone tell me if turning on the AUTO_UPDATE_STATISTICS option will have any adverse effects on performance? I've read that it is possible for it to adversely affect performance, because SQL Server “takes a quick break to update database statistics in the middle of the day”. The book does not explain why and I'm always leery of simply accepting something, simply because I’ve read it from a book. This is the first time that I’ve ever heard this and cannot find anything from SQL BOL or any other source.

View 2 Replies View Related

IDENTITY_INSERT, Is It A Good Idea?

Sep 14, 2006

Hi,

Today I discovered this command completely by accident and thought that ther are several places which we could use it in our apps.

Talking with a colleague, he is not to sure as it new to him too.

By using this to recover lost identity values, would this have any possible adverse effects on the table, indexes etc.

I can see potential problems when constraints are set between tables/keys. Anyone with any experience using this good and bad would be useful to hear.

Thanks

Adam

View 4 Replies View Related

Is Dropping Distribution Db A Good Idea?

Jan 29, 2008

What would happen if I dropped the distribution db?

I'm having problems configuring distribution and after searching, I found someone that claims they solved the same problem by dropping the distribution db. The resolution is the last post on this thread: http://www.ureader.com/msg/11563430.aspx

Is this safe to do? There are currently no publications and the distribution server is not configured.

Thanks

View 4 Replies View Related

Is It Good Idea To Replicate Sql Server Db Files?

Jul 20, 2005

Hi.I am wondering if it is a good idea to replicate sql server db filesusing frs.I don't really know how the frs works, sodoes frs replicates the whole database from time to time or just theportion that is changed?Also if the db is expected to change very often, and wouldn't it makethe whole system down?I wonder if it's a good idea just to make a backup of the database andcopy it.What's the usual practice?

View 3 Replies View Related

Is It A Good Idea To Install SQL On Exchange Server?

Nov 16, 2007



I am out of my element here but I have someone who is working on a project for me that entails him migrating our Access database to sql. He wants to load the sql software on our exchange server but our IT guy is saying this is not a good idea. Any thoughts???

Thanks,

Beth

View 5 Replies View Related

Is It A Good Idea To Use SQL2005 MDF For Audit, Exception Tracking

Feb 24, 2007

I am writing a web application that uses a Teradata database as the primary data source.  While Teradata is great as a data warehouse and managing Terabytes of information it doesn't do as well when update or inserting.  I was thinking of using a local SQL2005 MDF file to hold a few reference tables and an audit table to collect usage information and exception database to capture any errors.
There could be a few thousand users of the web application but no more than a couple hundred at a time.
I just trying to get some opinions on these technique.  I am open to all comments and suggestions.
Thank You 
 
 
 

View 2 Replies View Related

Stored Procs And Source Safe Good Idea?

Sep 25, 2000

Hi,
Any pros and cons of putting sprocs into Source Safe?

Thanks,
Judith

View 2 Replies View Related

Need Advice - A Delay Timer In Retrieving Remote Data, A Good Idea?

May 21, 2008

I have an application that automatically reads a lot of data from a third-party application into my database, via XML. For example, I might read a couple thousand rows-worth of XML data, one row at a time in a foreach loop.
To reduce the load on their server and database, I thought about putting a 2 second delay in between each of my automatic requests. Would this really help much, or is there enough overhead (setting up/tearing down connections, etc) with each request that it wouldn't reduce server load much anyway?
Is 2 seconds enough? Too little or too much? 

View 3 Replies View Related

Can You Explain This Error To Me? The Relation Property Of The Role Xxx Refers To The Target End Of Relation Xxx Which Is No

Mar 29, 2007

I'm getting this warning each time I auto-generate my model. I'm using named queries with logical primary keys.

The relation property of the role "xxx" refers to the target end of relation "xxx" which is not bound to a set of uniquely contrained columns.

I've searched and can't figured out what I am being warned about and whether I need to fix something. Can you help?

Thanks,
Toni



View 1 Replies View Related

How To Get This Relation(Need Sql Query)?

Dec 6, 2007

 Hi friendsI have one Table called tblCategory.I have three Column CatID, CatName, ParentIDI have many records in this TableCatID    CatName    ParentID1            Cat1            0 2            Cat2            13            Cat3            14            Cat4            25            Cat5            26            Cat6            07            Cat7            68            Cat8            69            Cat9            710          Cat10           711         Cat11            8  Here I have Main Category which has ParentID  0 [ Cat1 and Cat6 ]I Have Sub categories of Cat1 Which has ParentID  1(CatID 1 of Cat1) [ Cat2 and Cat 3 ]Cat 2 has also sub category with ParentID 2 (CatID 2 of Cat2) [ Cat4 and Cat5]I want result looks like asCat1                        Cat6       ->>>>>ParentID 0- Cat2                      -Cat7      ->>>>>ParentID 1(CatID of Root Cat1) and ParentID 6(CatID of Root Cat6)- - Cat4                     - -Cat9   ->>>>>PaerntID 2(CatID of Root Cat2) and ParentID 7(CatID of Root Cat7)- - Cat5                     - -Cat10   ->>>>>PaerntID 2(CatID of Root Cat2) and ParentID 7(CatID of Root Cat7) - Cat3                      -Cat8      -->>>>>ParentID 1(CatID of Root Cat1) and ParentID 6(CatID of Root Cat6)--No record               --Cat11    Can anybody give me solution?Thanks 

View 4 Replies View Related

Add Relation To New Table

Dec 29, 2003

If i add a new table to my database with a stored procedure, using that same sp or another can i also add a 1-M relationship with another table that is currently in the database. Please if you can provide an example.

Thank you,

View 1 Replies View Related

First Occurrence From 1 To Many Relation

May 12, 2006

This one shouldn't be too hard to do, just can't seem to figure it out.

I have two tables
tNames which contains 'ID' and 'Name'
tLocations which contains 'ID' and 'Location'

each ID may be associated with many Locations

I want to run a query to display these results:
[ID, Name, Location]

but only to return the first Location associated with that ID (or the max, min, I don't really care as long as it's only one result)

right now I have

Code:


SELECT tNames.ID, tNames.Name, tLocation.Location
FROM tNames INNER JOIN tLocations
ON tNames.ID = tLocations.ID



but this returns a new row for each different Location of the same ID

Thanks.

View 3 Replies View Related

Foreign Key Relation

Jun 18, 2007

hi all

i want to insert null values into a column which is a foreign key
It has relation form other table.Is it possible to insert null to such a field .if so please tell the synatax to insert(i mean the process)

Thanks In Advance

Malathi Rao

View 3 Replies View Related

Remove Relation

Feb 12, 2008

Hi everyone...got a question.

How could i remove a relation from 2 tables using a script?

Thanks

RON
________________________________________________________________________________________________
"I won't last a day without SQL"

View 1 Replies View Related

Relation && Query

Jul 23, 2005

Hello,I'm relative new to sql and databases and the last few weeks I learnedmyself a lot. I'm trying to make a hotel reservation application.I have a database with a table Booking, a table Room, a tableRoomsPerBooking. So a booking contains date/time etc and a fieldRoomsPerBookingID. The table RoomsPerBooking contains number ofpersons, unitprice etc. and a field ID and a field RoomID. The tableRoom contains data like name, notes etc.now i have two questions:First about relations:The table Booking has relationship: PK table RoomsPerBooking - ID <-->FK table Booking - RoomsPerBookingID.The table RoomsPerBookingID has relationship: PK table Room - ID <-->FK table RoomsPerBooking - RoomIDIs this relationset good for my purpose? I think it is, but I am notsure.The second question is:How do I get available rooms per nightI came this far.... what are the "some statements"?CREATE PROCEDURE dbo.GetAvailableRooms(@BeginDate DATETIME,@EndDate DATETIME)ASSELECT Room.*FROM RoomWHERE Room.ID NOT IN (SELECT DISTINCT room.IDFROM Room room JOIN RoomsPerBooking roomsPerBookingON room.ID = roomsPerBooking.RoomID--Some statements--WHERE booking.FromDate <= @EndDateAND booking.ToDate >= @BeginDate)GO

View 1 Replies View Related

Any Idea?

Mar 4, 2008

i have a table FORUM_REPLY it contain follwing fieldsquest_id,answer_id, reply_user_id.i want who is post most answer.so i need reply_user_id and max(no_of_answer).but following query given reply_user_id and no_of_answer onlySELECT reply_user_id,count(answer_id) as no_of_answer FROM FORUM_REPLY  GROUP BY(reply_user_id)How to get max_no_of_answer? 

View 13 Replies View Related

Can A DTS Do This For Me , If So, Any Idea How?

May 21, 2001

Hi all,

I am new to the DTS game - or at least to trying to do anything other than transfer rows between databases with identical structures.

I now need to create a far more complex DTS package to transfer data between an SQL Server database (I am using SQL Server 7.0) and an Oracle database. I have no trouble in making the connections and performing simple DTS's beween the two.

However, my current task is more complicated.

Problem 1:
In one database I would store fifty values as 5 five records each containing 10 values (i.e. has ten fields). However, in the other database these fifty values would all be stored as one record (i.e. one row with 50 fields). How could I go about creating a DTS to transfer this information?

Problem 2:
These values should only be transfered if certain conditions are met in an another unrelated table. For example, a flag in another table indicating that transfer of the said values should occur.

Any help with either of these problems would be much appraciated.

Thanks in advance,
Ross

View 3 Replies View Related

Any Idea&#39;s On 605

Nov 16, 2000

When one of the users log into the database via a thrid party application
they receive an error message:

2000/11/16 10:40:13.84spid51Error : 605, Severity: 21, State: 1
2000/11/16 10:40:13.84spid51Attempt to fetch logical page 7832 in database 'highview' belongs to object '1241055457', not to object 'application_data'.
2000/11/16 10:45:07.68spid46Getpage: bstat=0x1008/0, sstat=0x80002110, disk
2000/11/16 10:45:07.68spid46pageno is/should be:objid is/should be:
2000/11/16 10:45:07.68spid460x1e98(7832)0x49f900e1(1241055457)
2000/11/16 10:45:07.68spid460x1e98(7832)0x4810b86f(1209055343)
2000/11/16 10:45:07.68spid46... extent objid 0, mask 0/0, next/prev=0/0
2000/11/16 10:45:07.68spid46... retry bufget after purging bp 0x2da7e060


I tried running DBCC checkdb, newalloc,& checktable to fix the probelm and than droping the table and rebuilding it but not success, any suggestion are
more than welcome.

View 1 Replies View Related

Need An Idea How To....

Jun 21, 2002

If anybody can suggest the most efficient way to "page" the output from a big and wide table (about 7000000 records) in order to display on the web in the user requested sort order. Sort order could be on at least 7 different columns from 50 of returned.

I need to find a solution to move to the next and previous page.

Any Idea?

Dim

View 2 Replies View Related

Just An Idea

Jul 23, 2004

what if I took this trigger and based it on a view rather then a table

CREATE TRIGGER TerminationUpdateTrigger ON EmployeeGamingLicense
FOR UPDATE
AS
INSERT INTO TERMINATION(Status,[TM #],LastName, FirstName, [SocialSecurityNumber], DateHired, Title)
SELECT STATUS, [TM#], LASTNAME, FIRSTNAME, [SSN#], HIREDATE, JOBTITLE
FROM Inserted
WHERE STATUS = 'TERMINATED'


CREATE VIEW dbo.Update_Terminations
AS
SELECT STATUS, TM#, LASTNAME, FIRSTNAME, SSN#, HIREDATE,
JOBTITLE
FROM dbo.EmployeeGamingLicense
WHERE (STATUS = N'TERMINATED')

Base the Trigger on this View rather then on the Table itself????

View 2 Replies View Related

Some Idea

Apr 27, 2008

Hi I'm new to sql and it would be great if someone could give some idea on how to do the following

This is the relational model:

Department(DeptNum, Descrip, Instname, DeptName, State, Postcode)
Academic(AcNum, DeptNum, FamName, GiveName, Initials, Title)
Paper(PaNum, Title)
Author(PaNum, AcNum)
Field(FieldNum, ID, Title)
Interest(FieldNum, AcNum, Descrip)



The question is :-
Which academics have the largest number of fields of interests? Return their academic number,
given name, family name, institution and total number of fields they are interested in. Your must use a
subquery in the sense that you must use 2 sql statements and use any of the following to connect both:-


1)Exists
2)Not exists
3)IN

View 5 Replies View Related

Someone Have Any Idea About It?

Sep 18, 2006

I have a table call CLIENTE and another table call ENDERECO where the CLIENTE table has the FOREIGN KEY of the ENDERECO table.

When I try INSERT COMMAND in C# this message is show.

The instruction INSERT conflicted with a constraint of FOREIGN FUNDAMENTAL "FK_CLIENTE_ENDERECO." The conflict happened in the database "E:ARQUIVOS DE PROGRAMASMICROSOFT SQL SERVERMSSQL.1MSSQLDATALINETEC.MDF", table "dbo.I ADDRESS", column 'IDENDERECO.'
The instruction was concluded.

I am a "little" lost.

Thanks.

View 3 Replies View Related

Do Anyone Have An Idea?

Mar 21, 2007

Hi there,



I have number of tasks in my control flow most of them are execute sql task. I want to update one of the column in my table when anyone of the task in the control get fails?

Please let me know if anyone have an idea how to do this.



Thanks and Regards





View 3 Replies View Related

Load Relation From Diagram

Oct 9, 2006

I have defined a relation between 2 tables in "database diagrams" (IDE)but when a fill my tables vith a sqldataadapter i obtaina tables without relations why??how i can reslve this problem?my code is:Dim da As New SqlDataAdapter("SELECT * FROM table1", cn)Dim ds As New DataSetda.FillSchema(ds, SchemaType.Source, "table1")da.Fill(ds, "table1")--> ds.tables(0).relations.count =0 !!!!!!!!????????!!!

View 5 Replies View Related

ASPNETDB Relation With My Databas

Sep 8, 2007

HI!I have a ASPNETDB as my login databas. but now i want to connect this databas or the aspnet_user table to my table, how do i?I want to check the username in aspnet_user table and select the same username in my table?I want to write all sql code in a sql file. so i want to know how i can connect to the sql file from my c# code?I hope somebody understand me...

View 2 Replies View Related

What Do We Call The Table That Does The N To N Relation

Dec 13, 2007

 When we have Table1 and Table2, then we
link both tables using a third table Table3 that relates n records in
Table1 to n records in table2, how do we call Table3? There is a name
in dataBase modeling for that, right?

View 1 Replies View Related

One To Many Relation Ship Vs Look Up Field

Jan 2, 2001

hi, If I want to make one to many relationship, I put the pk of the parent as a fk in the child . like this
customer table (cust_id, fname,lname)
customer_order table(order_id,cust_id,qty,price)

I do understant this, but what about look up table, can I consider cust_id inthe customer_order table as a lookup field to the customer table?

Thanks
Al

View 1 Replies View Related

Stored Procedure And Many To Many Relation

Mar 13, 2008

Hi,

This is my table setup

http://www.mshelp.be/img/logs.JPG

I want to retrieve the logs by profileId.

This is the stored procedure which I'm using. Don't get any syntax error, only not the correct output.


create procedure sp_Select_log_By_ProfileId
@ProfileId int
as
select
l.LogId, l.LogDescription, l.CreatedOn, l.LogAuthorId
from
Logs l inner join ProfileLogs pl
on
pl.LogId = l.LogId
where
pl.ProfileId = @ProfileId;


Can anyone help me ?

View 5 Replies View Related

Sql Code For UML Composition Relation - Anyone?

Jan 19, 2007

hi, I got confused for a moment about creating data structure for UMLcomposition (strong aggregation) relation one-to-many.I used Rose/DataModeler to do so.[Parent] <filled_diamond>-------- [Child]I got P/FK (primary key of my component is foreign key of it's container) inmy child table:Parent: PK Parent_IDChild: P/FK Parent_IDthat way I found out I got relation 1:1, I'm still not sure how to createdata structure realizing compositiona one-to-many.

View 4 Replies View Related

Relation Between 2 Tables In Different Databases

Nov 18, 2007

Hi All,
I have a little problem and i hope u will help me.
Well, my problem is, i want to make a relation between 2 tables which r not in the same databse.
Database D1 >>> Table T1
Database D2 >>> Table T2

So i want something like this:
Table T1:
ID >>> PK

Table T2:
ID >>> PK
Table1ID >>> FK from Table T1

so, i will have a relation between the 2 tables.
Thanks in Advance,

View 1 Replies View Related







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