relational database tuple relationship Calculus language alpha

Source: Internet
Author: User

Relational calculus: based on predicate calculus in mathematical logic

Different classification by predicate variable

1. Tuple Relationship calculus:
Primitive objects with tuple variables as predicate arguments
Tuple Relationship Calculus Language alpha
2. Domain Relational calculus:
Base object with domain variable as predicate argument
Domain Relational Calculus language QBE

tuple Relationship Calculus language Alpha

(1) Simple search (i.e. without conditional search)

Format: GET workspace name (expression 1)
Check the number of all elective courses.
GET W (SC. Cno)

(2) Limited search (i.e. conditional search)

Format: GET workspace name (expression 1): Operating conditions
Inquiry Information Department (IS) the number and age of students younger than 20 years of age.
GET W (Student.sno, student.sage): student.sdept= ' is ' ∧student.sage<20

(3) Search with sorting

Format: GET workspace name (expression 1) [: Operating condition] Down/up expression 2
Query the Computer Science Department (CS) student's number, age, the results are sorted by age in descending order.
GET W (Student.sno, student.sage): student.sdept= ' CS ' down student.sage

(4) Search with quotas

Format: GET workspace name (quota) (expression 1) [: Operating conditions] [down/up expression 2]
Take out an information department student's school number.
GET W (1) (STUDENT.SNO): student.sdept= ' is '

(5) Retrieval of meta-group variables

1 2 tuple variable purpose
simplified relationship name: A tuple variable with a shorter name instead of a longer relationship name.
when using quantifiers in operating conditions, you must use a tuple variable.
3 define tuple variables
format: RANGE relationship name Variable name
A relationship can set multiple tuple variables
query information Student's name
RANGE Student X  get W (x.sname): x.sdept= ' is '

(6) Search with existential quantifiers

Check the name of the student taking course No. 2nd.

RANGE SC x GET W (student.sname): Εx (x.sno=student.sno∧x.cno= ' 2 ')

Inquire at least one of the students whose first course is 6th
RANGE Course CX SC SCX
GET W (student.sname):
E SCX (SCX. Sno=student.sno∧
E CX (CX. Cno=scx. cno∧cx.pcno= ' 6 '))

(7) Retrieval of an expression with multiple relationships

Student names and course names with a score of 90 or more

RANGE SC SCX GET W (Student.sname, course.cname):? SCX (SCX. Grade≥90∧scx.sno=student.sno∧course.cno=scx. Cno)

(8) searching with the full-name quantifier

Check the name of the student who does not select Course No. 1th.
RANGE SC SCX
GET W (Student.sname): V (Any)SCX (SCX. Sno≠student.sno∨scx.cno≠ ' 1 ')

(9) using two kinds of classifiers to search

Check the name of the student who has enrolled in all courses.

(10) Retrieval of the Yun Letter (implication)

(11) Set function

Find out the number of students in your department.

GET W (COUNT (student.sdept))
The Count function automatically excludes duplicate values when counting.

Update Action

(1) Modify operation

hold workspace name (expression 1) [: Operating conditions]

transfer 95007 students from computer Science department to Information system
hold W (Student.sno, STUDENT.SDETP): student.sno= ' 95007   
move ' is ' to w.sdept update W (Return the modified tuple back to the student relationship)

(2) Insert Operation

Create a new tuple in the workspace with the host language
Put the tuple into a put workspace name (relationship name) in the specified relationship with a put statement

The school has opened a new 2-credit course? Computer organization and structure? , the course number is 8 and the direct course is 6th. Insert the course tuple
MOVE ' 8 ' to W.cno
MOVE ' Computer organization and structure ' to w.cname
MOVE ' 6 ' to W.cpno
MOVE ' 2 ' to W.ccredit
PUT W (Course)

(3) Delete operation

Use the Hold statement to read the tuple to be deleted from the database into the workspace
Remove the tuple delete workspace name with the DELETE statement

95110 students drop out for a reason and delete the student's tuple.
Hold W (Student): student.sno= ' 95110 '
DELETE W

relational database tuple relationship Calculus language alpha

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.