SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


The Truth Table


The Truth Table

Author
Message
Tom Leeson
Tom Leeson
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 6

There are times where you can store flags in one column - these are bitwise flags 1 2 4 8 16 32 64 etc

This can be very handy - if you dont know why - then dont comment.

It could well be that are occasions where this generic code could be very useful too.


R2ro
R2ro
Old Hand
Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)

Group: General Forum Members
Points: 353 Visits: 134

A little leisure reading for those of you that may be a little rusty on the topic of propositional logic:

http://www.earlham.edu/~peters/courses/log/terms2.htm

Although lacking a specific example of its use, the article was well done. It allowed me to dip my toe in the XML pool without drowning at the same time bringing back memories of coding in i8080A machine language, front panel switch input and LED output on my IMSAI 8080 (31 years old & still kickin')!

An understanding of low level topics such as logic, binary (octal & hex, too), discrete electronics, relational math, etc. has made life a great deal easier as a programmer and as a DBA. Do not dismiss the basics!

...and yes, the Bowmar Brain was a wonderful tool but it would not have been nearly as valuable without the understanding of manual cypherin' (as Jethro Bodine would say). Try your hand at a little long division, square roots or bit masking. It will go a long way to improving your understanding of what those electrons are really doing in there!

Just my $0.02


yousef Ekhtiari
yousef Ekhtiari
SSChasing Mays
SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)

Group: General Forum Members
Points: 637 Visits: 48
I would like to thank you for your comment especially Cheryl Marsh .
I did not mean to show off myself,I just wanted to share my Idea with you.
If you have seen my previous article,you may find that the idea behind this procedure code is self-explanatory.


I knew that there is a 3rd value for bit that is UNKNOWN,but there are only 2 values
in propositional logic :true and false ,not more,so I did not need to deal with UNKNOWN
values.


consider the following table:

create table #stu(
id int,
sex char(1) check( sex in( 'm','f')),
grade char(1),
courseTaken int
)

we are asked to make a report that show all the students with
these conditions:
if the student has a score='a' then sex must be 'f' .
if the student has a score='b' then courseTaken must be greater than 7.

so the question implicitly says that the other students that do not meet aforementioned
condition should be in result set
since there is no Implies operator in SQL you need to use the following formula
p IMP Q==~P | Q

if you call

insert #stu
select 1,'f','a',4
union all
select 2,'m','a',10
union all
select 3,'f','b',8
union all
select 4,'m','a',5
union all
select 5,'f','c',6
union all
select 6,'f','b',5
union all
select 7,'f','c',6

select *
from #stu
where (grade<>'a' or sex='f')
and (grade<>'b' or courseTaken>7)

drop table #stu


I do agree this is not a clear example, but I have used it more often than not ;hope it gives you some idea
when implies operator will come in handy.

--Yousef Ekhtiari



Peter Thornqvist
Peter Thornqvist
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 2
Here's how to write xml entity replacements in html:

&amp;amp;
&amp;lt;
&amp;gt;
&amp;quot;
&amp;apos;

This will display as:

&amp;
&lt;
&gt;
&quot;
&apos;
Dennis D. Allen
Dennis D. Allen
SSC-Enthusiastic
SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)

Group: General Forum Members
Points: 199 Visits: 163
we are asked to make a report that show all the students with
these conditions:
if the student has a score='a' then sex must be 'f' .
if the student has a score='b' then courseTaken must be greater than 7.


I think this is an unclear method of stating a business requirement. If I were to receive this as my requirements with a request for all rows that violate this rule, I would write;

SELECT id, sex, grade, courseTaken
FROM #stu
WHERE
(grade = 'a' AND sex != 'f') -------- those that fail the first condition
OR (grade = 'b' AND courseTaken <= 7) -- those that fail the second condition

(~P | Q) for the first rule would read
"IF the student does not have a score of 'a' THEN sex may or may not be 'f'"

And those that satisfy this test (anyone with out a grade of 'a') are not in violation of the original first rule. They are in compliance by implication. The issue is, that the only way the rule can be broken is if the condition is met and the expectation is not met. If the condition is not met, then there is no expectation...
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search