|
Hi .
I have three entities that are related to each other . So these entities have relationships with each other but the problem here is that their relationships finally make a closed path . Would you please tell me what should i do in situations like this ?
I do not know even this is about normalization or not?
Entities :
Media ( MediaID , MediaName , ...,GroupID)
Articles (ArticleID , Title,... ,GroupID)
Groups (GroupID , GroupName ,... )
Article_Media ( MediaID, ArticleID, ...)
thanks
Give me the solution because in update we can not update the records
|
|
|
|
|
The only thing about an update that I can see failing whould be if you are updating one of the ID columns. Assuming that these are keys of some sort, you shouldn't be doing that anyway. If you can provide more information about what fails, that would be useful. Thanks.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Can you describe in some detail what Media and Articles are and how they relate to each other? Can you also describe what the Groups entity is about?
|
|
|
|
|
You need a group before you can create Media, Articles or a.. group? I hope that GroupID is nullable?
That's the only circular reference, the one in Groups. If the GroupID is nullable, you create one, then Media and Articles.
yousefshokati wrote: I do not know even this is about normalization or not?
It is. Those rules make you think about your design and gives you a neat way of getting some relevant structure in there. As it's now, it's merely a collection of field-names.
yousefshokati wrote: Give me the solution
The solution is easy, you need to rethink your design. About what each entity and each attribute are going to represent, and how they relate. Normalization is about getting that structure.
Good luck.
Bastard Programmer from Hell
|
|
|
|
|
Hi And tanks for your answer .
You say that When we design our database , we should design in a way that we do not have any closed path ?
Am I right?
But if we have 2 different relationship between 2 entities , then what should we do . Consider the following example :
We have MembersTable Which represents the members of teams and we have TeamsTable That represents the Team Entity Now We have to relations between these 2 . The First relation is "Plays For" which means that "Member Plays for team A for example " and the second is "Captain Of" which stands for "Members x is captain of team A" . Now if we update one of these FK s that are in tables for creating the relationships then we will get an error , won't be?
|
|
|
|
|
yousefshokati wrote: Hi And tanks for your answer
You're welcome
yousefshokati wrote: You say that When we design our database , we should design in a way that we do not have any closed path ?
Am I right?
I'm saying that you should normalize the design; that will eliminate all weird stuff from the design and give you something you can work with. I know that it's a bit of an investment in terms of time, but it repays itself rather quickly.
yousefshokati wrote: We have MembersTable Which represents the members of teams and we have TeamsTable That represents the Team Entity Now We have to relations between these 2 . The First relation is "Plays For" which means that "Member Plays for team A for example " and the second is "Captain Of" which stands for "Members x is captain of team A" . Now if we update one of these FK s that are in tables for creating the relationships then we will get an error , won't be?
Yes, you will. Normalization would state that you don't need the second entity.
MembersTable
MemberId
MemberName
IsCaptain
Best wishes for the year to come
Bastard Programmer from Hell
|
|
|
|
|
hello guys... I have this stored proc which gets some values from table but in addition, it calculates some values like %age of result. The question is: how can I send this value <b>WITH</b> a column name like <i>Percantage</i>. Here is the query for stored proc but I dont know what to add
<pre lang="SQL">
CREATE PROCEDURE [dbo].[GetStudents] AS
SELECT
s.StudentId, s.FirstName,s.SurName,
( ((s.ObtMarks) / (s.TotalMarks)) * 100) --this is the value I want to send with column name
FROM Students s
GROUP BY
s.StudentId, s.FirstName,s.SurName
</pre>
-- modified 28-Dec-11 7:30am.
|
|
|
|
|
Hi,
try giving your calculate column value an alias.
Then you can reference it by name in your c# datatable.
I've modified (but no tested or ran) your procedure.
Hope it helps,
CREATE PROCEDURE [dbo].[GetStudents] AS
SELECT
s.StudentId, s.FirstName,s.SurName,
( ((s.ObtMarks) / (s.TotalMarks)) * 100) AS PercentageValue
FROM Students s
GROUP BY
s.StudentId, s.FirstName,s.SurName
|
|
|
|
|
just put
colName = Calculated Value
and you are good to go
|
|
|
|
|
just change the query like this..
SELECT
s.StudentId, s.FirstName,s.SurName,
( 'Percentage - ' + ((s.ObtMarks) / (s.TotalMarks)) * 100) as 'Percentage'
hope it works..
with regards
Karthik Harve
|
|
|
|
|
can be a useful keyword.
|
|
|
|
|
Provided you don't misspell it by adding an extra 's'
|
|
|
|
|
I have a select query that returns a some rows . i want to send
each of the rows in returned result to a function but i do not know how ?
can you help me
"Note that i do not want to use Cursor "
select PersonelCode , ...
from PersonnelTable
-------------------------------------
and the function Need the PersonelCode.For each row this function should be executed
Create Function MyFunction ( @PersonelCode )
begin
body of the function
end
|
|
|
|
|
Hi,
Check the following Script,
It will be use full for ur Query..........
SET NOCOUNT ON
DECLARE @Employee TABLE(ID INT , EmpName VARCHAR(40))
DECLARE @I INT, @Count INT, @Temp VARCHAR(50)
SET @I = 1
INSERT INTO @Employee(ID,EmpName)
SELECT 123,'Prabu'
UNION ALL SELECT 234, 'Raja'
UNION ALL SELECT 236, 'Kartik'
UNION ALL SELECT 1234, 'Venkat'
SELECT @Count=COUNT(*) FROM @Employee
PRINT '~~~~~~~~~~~~~~~~~'
PRINT 'Employee Details'
PRINT '~~~~~~~~~~~~~~~~~'
WHILE @I <= @Count
BEGIN
WITH Emp AS
(
SELECT row_number() OVER ( ORDER BY ID ) 'RowNum', ID, EmpName
FROM @Employee
)
SELECT @Temp =CAST(ID AS VARCHAR) +' - '+EmpName
FROM Emp
WHERE RowNum =@I
PRINT @Temp
SET @I=@I+1
END
PRINT '~~~~~~~~~~~~~~~~~'
SET NOCOUNT OFF
|
|
|
|
|
And the following doesn't do it?
select PersonelCode , MyFunction(PersonelCode), ...
from PersonnelTable
|
|
|
|
|
I have a select query that returns a some rows . i want to send
each of the rows in returned result to a function but i do not know how ?
can you help me
select PersonelCode , ...
from PersonnelTable
-------------------------------------
and the function Need the PersonelCode.For each row this function should be executed
Create Function MyFunction ( @PersonelCode )
begin
body of the function
end
|
|
|
|
|
|
How about
SELECT PersonelCode ,MyFunction(PersonelCode), ... FROM PersonnelTable
|
|
|
|
|
i'm trying to filter by date using query but error.
select s.IdStaff, s.NamaStaff,
sum(pd.Qty *
case s.posisi
when 'K.Teknisi' then kd.komisiteknisi
when 'K.Controller' then kd.komisitelemarketing
when 'K.Manager' then kd.komisicontroller
when 'K.TeleMarketing' then kd.komisimanager
when 'K.Cadangan' then kd.komisicadangan
end) Insentif
from staff s inner join penjualan p on s.idstaff = p.idstaff
inner join penjualandetail pd on p.idpenjualan = pd.idpenjualan
inner join komisidetail kd on pd.idbarang = kd.idbarang
where p.tglpenjualan between 12/1/2011 and 12/30/2011
group by s.idstaff, s.namastaff
error message : Msg 206, Level 16, State 2, Line 1
Operand type clash: date is incompatible with int
|
|
|
|
|
Use quotes around the dates and check that the format of the dates is valid.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
perfect !!
wondering why i always forgot that even after my teacher told me twice.
how about the date format?
is it YYYY/MM/DD or MM/DD/YYYY or else?
thanks before..
|
|
|
|
|
|
vkstarry wrote: YYYY/MM/DD
always works.
vkstarry wrote: MM/DD/YYYY
might work depending on your date settings.
|
|
|
|
|
Hi . I have written an assembly in which it has two user defined functions . In sql when i create the assemblies , it does not make any errors even when i create my first function again i do not have any errors but when i create the second function , the server computer has this error , the most intresting thing for me is that i have installed all of them in another computer and it worked but in my server it has this error
can you help me ?
the error is :
" Failed to open malformed assembly 'mscorlib' with HRESULT 0x80070008. "
|
|
|
|
|
googling for Failed to open malformed assembly with HRESULT 0x80070008 turned up this[^]. Check your disk!
|
|
|
|