Solved

Predicate Logic, T-SQL

Posted on 2015-01-31
9
135 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
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
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 33

Author Comment

by:Mike Eghtebas
Comment Utility
I was hoping for some illustration/demonstration if possible.
0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
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
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
Be careful with posting, because of copyright...
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
Comment Utility
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 33

Author Comment

by:Mike Eghtebas
Comment Utility
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
Comment Utility
And I have answered your question above.
0
 
LVL 33

Author Comment

by:Mike Eghtebas
Comment Utility
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 33

Author Closing Comment

by:Mike Eghtebas
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now