Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

The Truth Table Expand / Collapse
Author
Message
Posted Friday, April 20, 2007 2:51 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, May 8, 2009 4:53 AM
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.

 

 

 

Post #359884
Posted Friday, April 20, 2007 7:09 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, May 7, 2012 10:05 AM
Points: 165, 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

Post #359960
Posted Friday, April 20, 2007 11:56 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Saturday, February 13, 2010 12:45 AM
Points: 553, Visits: 18
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



Post #360120
Posted Sunday, April 22, 2007 3:12 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, March 1, 2008 3:06 AM
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;
Post #360152
Posted Wednesday, April 25, 2007 11:02 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, June 5, 2012 12:03 PM
Points: 117, 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...
Post #360922
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse