《Database System Concepts(数据库系统概念)》第六版——第五次作业(第四、六、七章)

本文讨论了数据库中如何使用GRANT命令进行权限授予,强调了只有拥有权限的经理才能进行此操作。同时,展示了几个SQL查询示例,包括查找特定公司员工,对比不同公司薪资,以及通过部门过滤课程和学生。这些查询涉及了表连接、投影、选择和集合操作。
摘要由CSDN通过智能技术生成

4.17

经理本身拥有权限,可以在grant命令后附加with grant option命令允许其进行权限授予;而用户本身不拥有权限,故不能进行权限授予

6.2

  • a

    Π e m p l o y e e . p e r s o n _ n a m e ( σ e m p l o y e e . m a n a g e r _ n a m e = w . p e r s o n _ n a m e ∧   e m p l o y e e . s t r e e t = w . s t r e e t ∧   e m p l o y e e . c i t y = w . c i t y ( ( e m p l o y e e ⋈ m a n a g e s ) × ρ w ( \Pi_{employee.person\_name}(\sigma_{employee.manager\_name=w.person\_name \wedge\ employee.street=w.street \wedge\ employee.city=w.city }((employee\bowtie manages) \times \rho_w( Πemployee.person_name(σemployee.manager_name=w.person_name employee.street=w.street employee.city=w.city((employeemanages)×ρw(

    e m p l o y e e ) ) ) employee))) employee)))

  • b

    Π p e r s o n _ n a m e ( σ c o m p a n y _ n a m e ≠ " F i r s t   B a n k   C o r p o r a t i o n " ( w o r k s ) ) \Pi_{person\_name}(\sigma_{company\_name \neq "First\ Bank\ Corporation"}(works)) Πperson_name(σcompany_name="First Bank Corporation"(works))

  • c

    Π p e r s o n _ n a m e ( e m p l o y e e ) − Π w o r k s . n a m e ( σ w . c o m p a n y _ n a m e = " S m a l l   B a n k   C o r p o r a t i o n "   ∧   w o r k s . s a l a r y < w . s a l a r y ( w o r k s × ρ w ( w o r k s ) ) ) \Pi_{person\_name}(employee)-\Pi_{works.name}(\sigma_{w.company\_name="Small\ Bank\ Corporation"\ \wedge\ works.salary<w.salary}(works\times \rho_w(works))) Πperson_name(employee)Πworks.name(σw.company_name="Small Bank Corporation"  works.salary<w.salary(works×ρw(works)))

6.4

  • a

    Π I D , c o u s e _ i d ( t a k e s ) ÷ Π c o u r s e _ i d ( σ d e p t _ n a m e = " C o m p . S c i . " ( c o u r s e ) ) \Pi_{ID,couse\_id}(takes)\div \Pi_{course\_id}(\sigma_{dept\_name="Comp.Sci."}(course)) ΠID,couse_id(takes)÷Πcourse_id(σdept_name="Comp.Sci."(course))

  • b

    Π I D ( σ d e p t _ n a m e = " C o m p . S c i " ( t a k e s ⋈ c o u r s e ) ) \Pi_{ID}(\sigma_{dept\_name="Comp.Sci"}(takes\bowtie course)) ΠID(σdept_name="Comp.Sci"(takescourse))

6.5

  • a

    {t| ∃ \exists x ∈ \in r(x[A]=t[A])}

  • b

    {t|t ∈ \in r ∧ \wedge t[B]=17}

  • c

    {t| ∃ \exists x ∈ \in r, y ∈ \in s (x[A]=t[A] ∧ \wedge x[B]=t[B] ∧ \wedge x[C]=t[C] ∧ \wedge y[D]=t[D] ∧ \wedge y[E]=t[E] ∧ \wedge y[F]=t[F])}

  • d

    {t| ∃ \exists x ∈ \in r, y ∈ \in s,(x[A]=t[A] ∧ \wedge y[F]=t[F] ∧ \wedge x[C]=y[D])}

6.6

  • a

    {<a>| ∃ \exists b,c(<a,b,c> ∈ \in r 1 r_1 r1)}

  • b

    {<a,b,c>|<a,b,c> ∈ \in r 1 r_1 r1 ∧ \wedge b=17}

  • c

    {<a,b,c>|<a,b,c> ∈ \in r 1 r_1 r1 ∨ \vee <a,b,c> ∈ \in r 2 r_2 r2}

  • d

    {<a,b,c>|<a,b,c> ∈ \in r 1 r_1 r1 ∧ \wedge <a,b,c> ∈ \in r 2 r_2 r2}

  • e

    {<a,b,c>|<a,b,c> ∈ \in r 1 r_1 r1 ∧ \wedge <a,b,c> ∉ \notin / r 2 r_2 r2}

  • f

    {<a,b,c>| ∃ \exists x,y(<a,b,x> ∈ \in r 1 r_1 r1 ∧ \wedge <y,b,c> ∈ \in r 2 r_2 r2) }

6.7

  • a

    Π A ( σ B = 7 ( r ) ) \Pi_{A}(\sigma_{B=7}(r)) ΠA(σB=7(r))

  • b

    r ⋈ \bowtie s

  • c

    Π A ( σ s . C = q . A ∧ r . b > q . b ( ( s ⋈ r ) × ρ q ( r ) ) ) \Pi_{A}(\sigma_{s.C=q.A \wedge r.b>q.b}((s\bowtie r)\times \rho_q(r))) ΠA(σs.C=q.Ar.b>q.b((sr)×ρq(r)))

6.11

  • a

    Π p e r s o n _ n a m e ( σ c o m p a n y _ n a m e = " F i r s t   B a n k   C o r p o r a t i o n " ( w o r k s ) ) \Pi_{person\_name}(\sigma_{company\_name = "First\ Bank\ Corporation"}(works)) Πperson_name(σcompany_name="First Bank Corporation"(works))

  • b

    Π p e r s o n _ n a m e , c i t y ( σ c o m p a n y _ n a m e = " F i r s t   B a n k   C o r p o r a t i o n " ( w o r k s ⋈ e m p l o y e e ) ) \Pi_{person\_name,city}(\sigma_{company\_name = "First\ Bank\ Corporation"}(works\bowtie employee)) Πperson_name,city(σcompany_name="First Bank Corporation"(worksemployee))

  • c

    Π p e r s o n _ n a m e , s t r e e t , c i t y ( σ c o m p a n y _ n a m e = " F i r s t   B a n k   C o r p o r a t i o n " ∧ s a l a r y > 10000 ( w o r k s ⋈ e m p l o y e e ) ) \Pi_{person\_name,street,city}(\sigma_{company\_name = "First\ Bank\ Corporation" \wedge salary>10000}(works\bowtie employee)) Πperson_name,street,city(σcompany_name="First Bank Corporation"salary>10000(worksemployee))

  • d

    Π p e r s o n _ n a m e ( σ w o r k s . c o m p a n y _ n a m e = c o m p a n y . c o m p a n y _ n a m e ∧ e m p l o y e e . c i t y = c o m p a n y . c i t y ( ( w o r k s ⋈ e m p l o y e e ) × c o m p a n y ) ) \Pi_{person\_name}(\sigma_{works.company\_name=company.company\_name \wedge employee.city=company.city}((works\bowtie employee)\times company)) Πperson_name(σworks.company_name=company.company_nameemployee.city=company.city((worksemployee)×company))

  • e

    Π c o m p a n y _ n a m e ( σ d . c o m p a n y _ n a m e = " F i r s t   B a n k   C o r p o r a t i o n " ∧ c o m p a n y . c i t y = d . c i t y ( c o m p a n y × ρ d ( c o m p a n y ) ) ) \Pi_{company\_name}(\sigma_{d.company\_name = "First\ Bank\ Corporation"\wedge company.city=d.city}(company \times \rho_d(company))) Πcompany_name(σd.company_name="First Bank Corporation"company.city=d.city(company×ρd(company)))

6.15

  • a

    {t| ∃ \exist s ∈ \in works(t[person_name]=s[person_name] ∧ \wedge s[company_name]=“First Bank Corporation”)}

    {<p>| ∃ \exist c,s(<p,c,s> ∈ \in works ∧ \wedge c=“First Bank Corporation” )}

  • b

    {t| ∃ \exist p ∈ \in employee, s ∈ \in works(t[city]=p[city] ∧ \wedge t[person_name]=p[person_name] ∧ \wedge t[person_name]=s[person_name] ∧ \wedge s[company_name]=“First Bank Corporation”)}

    {<p,ci>| ∃ \exist st,c,s(<p,st,ci> ∈ \in employee ∧ \wedge <p,c,s> ∈ \in works ∧ \wedge c=“First Bank Corporation” )}

  • c

    {t|t ∈ \in employee, ∃ \exist s ∈ \in works(t[person_name]=s[person_name] ∧ \wedge s[company_name]=“First Bank Corporation” ∧ \wedge s[salary]>10000)}

    {<p,st,ci>| ∃ \exist c,s(<p,st,ci> ∈ \in employee ∧ \wedge <p,c,s> ∈ \in works ∧ \wedge c=“First Bank Corporation” ∧ \wedge s>10000)}

  • d

    {t| ∃ \exist x ∈ \in employee, y ∈ \in works, z ∈ \in company (t[person_name]=x[person_name] ∧ \wedge x[person_name]=y[person_name] ∧ \wedge y[company_name]=z[company_name] ∧ \wedge x[city]>z[city])}

    {<p>| ∃ \exist st, ci1, c, s, ci2 ( <p,st,ci1> ∈ \in employee ∧ \wedge <p,c,s> ∈ \in works ∧ \wedge <c,ci2> ∈ \in company ∧ \wedge ci1=ci2)}

  • e

    {t| ∃ \exist x ∈ \in employee, y ∈ \in managers, z ∈ \in employee (t[person_name]=x[person_name] ∧ \wedge x[person_name]=y[person_name] ∧ \wedge y[manager_name]=z[person_name] ∧ \wedge x[street]>z[street] ∧ \wedge x[city]>z[city])}

    {<p>| ∃ \exist st1, ci1, m, st2,ci2 ( <p,st1,ci1> ∈ \in employee ∧ \wedge <p,m> ∈ \in manager ∧ \wedge <m,st2,ci2> ∈ \in employee ∧ \wedge ci1=ci2 ∧ \wedge st1=st2)}

  • f

    {t| ∃ \exist s ∈ \in works(t[person_name]=s[person_name] ∧ \wedge s[company_name] ≠ \neq = “First Bank Corporation”)}

    {<p>| ∃ \exist c,s(<p,c,s> ∈ \in works ∧ \wedge c ≠ \neq = “First Bank Corporation” )}

  • g

    ¬ \neg ¬{t| ∃ \exist s, w ∈ \in works(s[person_name]=t[person_name] ∧ \wedge w[company_name]=“Small Bank Corporation” ∧ \wedge s.salary<w.salary)} ∧ \wedge {t| ∃ \exist s ∈ \in employee(s[person_name]=t[person_name])}

    ¬ \neg ¬{<p1>| ∃ \exist s1, c1, p2, s2, c2 (<p1,c1,s1> ∈ \in works ∧ \wedge <p2,c2,s2> ∈ \in works ∧ \wedge s1<s2)} ∧ \wedge {<p>| ∃ \exist s,c (<p,s,c> ∈ \in employee)}

  • h

    {t| ∃ \exist x ∈ \in company, y ∈ \in company(t[company_name]=x[company_name] ∧ \wedge x[city]=y[city] ∧ \wedge y[company_name]=“Small Bank Corporation”)}

    {<ci1>| ∃ \exist c1,c2,ci2(<c1,ci1> ∈ \in company ∧ \wedge <c2,ci2> ∈ \in company ∧ \wedge c2=“Small Bank Corporation” ∧ \wedge ci1=ci2)}

7.1
在这里插入图片描述

7.2

  • student
    grade
    section
    exam
  • student
    exam
    section
    exam_id,grade
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值