Professional Documents
Culture Documents
1. Consider the employee database of Figure 2.1. Give an expression in the relational
algebra to express each of the following queries:
a. Find the ID and name of each employee who works for “BigBank”.
b. Find the ID, name, and city of residence of each employee who works for
“BigBank”.
c. Find the ID, name, street address, and city of residence of each employee who
d. Find the ID and name of each employee in this database who lives in the same
a.
Π perso n ( σ city=BigBank ( company ) ⊳ ⊲company .compan y
name name =works .compan y name ( works ) ⊳ ⊲works . person name =employee. person name ( employee ))
b.
Π person name ,city (σ city=BigBank ( company ) ⊳ ⊲company .company name =works . company name ( works ) ⊳ ⊲works . person name =employee. person name ( employee ))
c.
Π person name , street , city (σ city=BigBank ⋀ salary >$ 10000 ( company ) ⊳ ⊲company . company name =works .company name ( works ) ⊳ ⊲works . person name =employee . personna
- Ngôn ngữ chức năng: mô hình lập trình chức năng được tạo ra một cách rõ ràng để hỗ
trợ một cách tiếp cận chức năng thuần túy để giải quyết vấn đề. Lập trình hàm là một
dạng của lập trình khai báo.
- Ngôn ngữ chức năng là một danh mục con của ngôn ngữ mệnh lệnh.
- Ngôn ngữ khai báo, còn được gọi là phi thủ tục hoặc cấp rất cao, là ngôn ngữ lập trình
trong đó (lý tưởng là) một chương trình chỉ định những gì sẽ được thực hiện hơn là cách
thực hiện. Hai loại ngôn ngữ khai báo phổ biến là ngôn ngữ logic và ngôn ngữ chức năng.
Ngôn ngữ chức năng là một dạng của ngôn ngữ khai báo
4. Write the following queries in relational algebra, using the university schema.
classroom(building, room number, capacity)
department(dept name, building, budget)
course(course id, title, dept name, credits)
instructor(ID, name, dept name, salary)
section(course id, sec id, semester, year, building, room number, time slot id)
teaches(ID, course id, sec id, semester, year)
student(ID, name, dept name, tot cred)
takes(ID, course id, sec id, semester, year, grade)
advisor(s ID, i ID)
time slot(time slot id, day, start time, end time)
prereq(course id, prereq id)
Figure 2.5 Schema of the university database.
a. Find the ID and name of each instructor in the Physics department.
b. Find the ID and name of each instructor in a department located in the building
“Watson”.
c. Find the ID and name of each student who has taken at least one course in the “Comp.
Sci.” department.
d. Find the ID and name of each student who has taken at least one course section in the
year 2018.
e. Find the ID and name of each student who has not taken any course section in the year
2018.
b. Π ID, name (σ building =Watson ( department ) ⊳ ⊲department . dept name =instructor .dept name ( instructor ))
d. Π ID, name ¿
e. Π ID, name ¿