Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

Predicate Logic, T-SQL

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
Mike Eghtebas
Asked:
Mike Eghtebas
  • 4
  • 2
  • 2
  • +1
1 Solution
 
QlemoC++ DeveloperCommented:
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
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
I was hoping for some illustration/demonstration if possible.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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 quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
QlemoC++ DeveloperCommented:
Be careful with posting, because of copyright...
0
 
Phillip BurtonCommented:
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
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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
 
Phillip BurtonCommented:
And I have answered your question above.
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now