Solved

Predicate Logic, T-SQL

Posted on 2015-01-31
9
182 Views
Last Modified: 2015-02-04
The following image is from the book I am reading (Exam 70-461). My question is on Predicate Logic portion of the image. I have the following description for it:

Predicate Logic: An expression that when attributed to some object, makes a proposition either true or false.

The relational model uses predicates as one of its core elements. A predicates can do the followings:
1-      Enforce data integrity.    
        <<< I need example or explanation for this >>>

2-    Filter data:                        <-- I have example for this
        Example: An order with
       -      order ID 10248 was placed
       -      on February 12, 2012
       -      by the customer with ID 7,
       -      and handled by the employee with ID 3.
You can evaluate this predicate for a specific order ID in WHERE clause.

3-      Define the data model.  
        <<< I need example or explanation for this >>>

You first identify propositions that need to be stored in the database.

Question: Could you please make an example or explain items 1 and 3 listed above?

PredicitLogic
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 70

Expert Comment

by:Qlemo
ID: 40582797
A predicate is the same as a condition. For data integrity purposes it's no different, but it is part of the table definition. You can say "value needs to be between 1 and 5" (a value domain constraint), or "value has to exist in column x of table y" (a foreign key).
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40582804
I was hoping for some illustration/demonstration if possible.
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 40582964
Send us a screen shot of the page in question.  I passed 70-461, and have no freeaking idea what is being asked here, and don't recall anything like this on the test.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 70

Expert Comment

by:Qlemo
ID: 40582988
Be careful with posting, because of copyright...
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40583847
It's taken from page 5 of the book.

In my view, they are a bit the same. For example, you can define a table which has a field saying "Do not accept this as a value unless the salary is >$50,000" (as per the previous paragraph), or if this value is NULL (missing).

For more information on predicates and set theory, have a read of 5. and 6. on this web page: https://sqldestination.wordpress.com/2012/12/29/sql-core-concepts-part-1-rdbms-sql-t-sql-set-theory-and-predicate-logic-relational-model/

But don't sweat about this part.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40587957
Hi Jim,

After a bit delay, here is the portion of the text from the book I am reading which relates to the question at hand:

"The other branch of mathematics that the relational model is based on is called predicate
logic. A predicate is an expression that when attributed to some object, makes a proposition
either true or false. For example, “salary greater than $50,000” is a predicate. You can evaluate
this predicate for a specific employee, in which case you have a proposition. For example,
suppose that for a particular employee, the salary is $60,000. When you evaluate the proposition
for that employee, you get a true proposition. In other words, a predicate is a parameterized
proposition.
The relational model uses predicates as one of its core elements. You can enforce data
integrity
by using predicates. You can filter data by using predicates. You can even use predicates
to define the data model itself. You first identify propositions that need to be stored
in the database. Here’s an example proposition: an order with order ID 10248 was placed on
February 12, 2012 by the customer with ID 7, and handled by the employee with ID 3. You
then create predicates from the propositions by removing the data and keeping the heading.
Remember, the heading is a set of attributes, each identified by name and type name. In this
example, you have orderid INT, orderdate DATE, custid INT, and empid INT."

Lesson 1: Understanding the Foundations of T-SQL Chapter 1 page 5
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40588090
And I have answered your question above.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40589578
Hi Phillip,

Thank you for the comments. After a reply to Jim's request, now I am at your good post.

On page 5 on the same book, we have:
"The relational model uses predicates as one of its core elements. You can enforce data
integrity
by using predicates. You can filter data by using predicates. You can even use predicates
to define the data model itself."

1- enforce data integrity Example:
The predicate is “salary greater than zero” (T-SQL expression: salary > 0). This predicate helps maintain the integrity of data as the database designer has envisioned.

2- filter data Example:
"You can also use predicates when filtering data to define subsets, and so on. For example, if you need to query the Employees table and return only rows for employees from the sales department, you would use the predicate “department equals sales” in your query filter (T-SQL expression: department = ‘sales’)."

3- define the data model Example:
"As an example of an infinite set defined with a predicate, the set of all prime numbers can be defined with the following predicate: “x is a positive integer greater than 1 that is divisible only by 1 and itself.” The set of all prime numbers is the set of all elements for which the predicate holds true."
0
 
LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 40590386
Thank you.

Predicate:
state, affirm, or assert (something) about the subject of a sentence or an argument of proposition.

Helped me, it may help some other readers.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question