Solved

Predicate Logic, T-SQL

Posted on 2015-01-31
9
143 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
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 33

Author Comment

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

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
 
LVL 68

Expert Comment

by:Qlemo
ID: 40582988
Be careful with posting, because of copyright...
0
[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

 
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 33

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 33

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 33

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

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.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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.

920 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

16 Experts available now in Live!

Get 1:1 Help Now