Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Predicate Logic, T-SQL

Posted on 2015-01-31
9
Medium Priority
?
214 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 71

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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 71

Expert Comment

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

Accepted Solution

by:
Phillip Burton earned 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
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
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

636 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