公司部门表(company)[company_id int identity,company_name varchar(12)],
 员工表(employee)[employee_id int identity,company_id int,empany_name varchar(12),employee_time varchar(12)入职时间] 备份表(backupCoEm)[backup_id int identity,company_id int,employee_id int,backuptime varchar(12)系统时间]   问题1 写出部门表 和 员工表 一对多 多对多的关系?(用hibernate)
   问题2 用一条sql写出每个部门的名称 和 部门的员工人数?
   问题3 用一条查出company_name='date_e' 的所有员工的详细信息?
   问题4 用一条把部门表company_name='date_e'和员工表的相关信息备份到backupCoEm中 并且插入系统时间

解决方案 »

  1.   

    问题一:
    <set name="employee" cascade=""save-update>
    <key="company_id"/>
    <one-to-many class = "company">
    </set>
    问题二: 
    select company_name,empNum from COMPANY C 
    left outer join (select count(*) empNum from EMPLOYEE e where c.company_id = e.company_id)
    问题三:
    select * from EMPLOYEE where company_id in (select company_id from COMPANY where company_name = 'date_e')
      

  2.   

    建张表 用 hibernate 生成一下 更透彻。