web连接mysql建立学生表_Web数据库学生实验报告2015版

《Web数据库学生实验报告2015版》由会员分享,可在线阅读,更多相关《Web数据库学生实验报告2015版(26页珍藏版)》请在人人文库网上搜索。

1、Web数据库技术教师实验指导手册及评分标准院 系: 信息科学与技术学院专 业: 信息管理与信息系统班 级: 信A1321/22任课教师: 张海 实验报告(一)院系:信息学院 课程名称:Web数据库技术 日期:班 级姓 名专 业学 号实 验 室实验名称Jdbc应用成 绩 评 定教 师 签 名实验目的1、 掌握数据库驱动的加载方式2、 掌握connection对象的使用方法3、 掌握statement对象使用方法4、 掌握事务的处理机制5、掌握数据持久层的设计实验内容connection对象、statement对象等应用1、 请设计一个工程类通过配置文件如下db.properties来获得数据库连。

2、接的相关信息,并通过该配置文件获得数据库连接对象。(20分)db.propertiesdriver=org.gjt.mm.mysql.Driverurl=jdbc:mysql:/127.0.0.1/u5B66u751Fu5E93userName=adminpwd=adminpublic class connectionFactory public static Connection getConnection() throws SQLException请把getConnection()方法补全。要求设计合理规范,必须有截图。答案:2、 已知学生定义如下:public class student。

3、 private int id;private String stuId;private String name;private String domCard;/楼栋宿舍号“31-507”private String bedNo;/床铺号public student(String stuId, String name, String domCard, String bedNo) super();this.stuId = stuId;this.name = name;this.domCard = domCard;this.bedNo = bedNo;public String toString(。

4、)return id=+id+;学号=+stuId+”;姓名=”+name+”;宿舍号=”+domCard+”;床铺号=”+bedNo;/相应get、set方法省略有一class studentDataspublic static ArrayList students=new ArrayList();staticstudent stu=new student(会计A,张三,31栋908,1);students.add(stu);stu=new student(会计A,李四,31栋908,2);students.add(stu);stu=new student(会计A,王五,31栋807,4);。

5、students.add(stu);现要求 (1)根据student类建立一个学生表用来保存student类的相关属性。(2)通过jdbc,将studentDatas的students集合中的所有学生保持到学生表中;(3)通过jdbc,将学生表中所有的宿舍是” 31栋908”学生全部调整到“20栋371”宿舍;(4)通过jdbc,删除31栋807床铺号是4的学生。20分3、 ResultSet对象操作请将上题中宿舍号最后一位是”8”的学生信息全部显示出来。4、请用perparedStatement对象保存如下:student stu=new student(信息A,刘六,31栋818,8);s。

6、tudent对象的实例stu到数据中。兴趣题:1、分页功能的实现原理方法一:JDBC实现用JDBC从ResultSet中取出一个指定范围(offset, span)的数据,可以采用这样的方法。PrepareStatement ps = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ps.setMaxRows(offset span);/最终读到第几条rs = ps.executeQuery();rs.absolute(offset);/定位到每页的开始记录处wh。

7、ile(rs.next()/ conn.prepareStatement(sql,游标类型,能否更新记录);/ 游标类型:/ ResultSet.TYPE_FORWORD_ONLY:只进游标/ ResultSet.TYPE_SCROLL_INSENSITIVE:可滚动。但是不受其他用户对数据库更改的影响。/ ResultSet.TYPE_SCROLL_SENSITIVE:可滚动。当其他用户更改数据库时这个记录也会改变。/ 能否更新记录:/ ResultSet.CONCUR_READ_ONLY,只读/ ResultSet.CONCUR_UPDATABLE,可更新方法二:数据库的sql语言实现My。

8、sql 的limit SQL为Select * from message where forum_id = ? and created_time ? order by created_time desc limit ?, ?后面的两个limit ?, ? 分别为 offset, span。Oracle的limit SQL为select * from ( select row_.*, rownum rownum_ from (Select * from message where forum_id = ? and created_time ? order by created_time desc。

9、) row_ where rownum ?后面的两个limit ?, ? 分别为 offset span, offset。2、请执行在mysql中执行insert into 宿舍表(学号,姓名,宿舍,床铺) values (会计A,张三,24栋908,1)两次。请通过JDBC将宿舍表中学号重复的记录去掉,只保留其中的一条。5、事务处理请先在mysql中运行如下语句:CREATE TABLE 账户表 (账户名 varchar(10) NOT NULL DEFAULT ,金额 double DEFAULT NULL,PRIMARY KEY (账户名) ENGINE=InnoDB DEFAULT C。

10、HARSET=utf8;- - Records of 账户表- -INSERT INTO 账户表 VALUES (张三, 100);INSERT INTO 账户表 VALUES (李四, 200);INSERT INTO 账户表 VALUES (王五, 50);请运行如下程序查看结果(1)程序1:public class trans1 /* param args*/public static void main(String args) Connection conn1=null;Statement stmn1=null;try conn1=connectionFactory.getConne。

11、ction();conn1.setAutoCommit(true);stmn1=conn1.createStatement();stmn1.executeUpdate(update 账户表 set 金额=金额+5 where 账户名=张三);System.out.println(update语句执行); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();finallyif(stmn1!=null)try stmn1.close(); catch (SQLException e) / TODO 。

12、Auto-generated catch blocke.printStackTrace();if(conn1!=null)try conn1.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();(2)程序2:public class trans2 /* param args*/public static void main(String args) Connection conn1=null;Statement stmn1=null;try conn1=connectionFa。

13、ctory.getConnection();conn1.setAutoCommit(false);stmn1=conn1.createStatement();stmn1.executeUpdate(update 账户表 set 金额=金额+5 where 账户名=张三);System.out.println(update语句执行); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();finallyif(stmn1!=null)try stmn1.close(); catch (SQLExcep。

14、tion e) / TODO Auto-generated catch blocke.printStackTrace();if(conn1!=null)try conn1.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();请查询数据库记录内容。(3)完整事务程序3:public class trans2 /* param args*/public static void main(String args) Connection conn1=null;Statement stm。

15、n1=null;try conn1=connectionFactory.getConnection();conn1.setAutoCommit(false);stmn1=conn1.createStatement();stmn1.executeUpdate(update 账户表 set 金额=金额+5 where 账户名=张三);conn1.commit();System.out.println(insert语句执行); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();try conn1.r。

16、ollback(); catch (SQLException e1) / TODO Auto-generated catch blocke1.printStackTrace();finallyif(stmn1!=null)try stmn1.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();if(conn1!=null)try conn1.close(); catch (SQLException e) / TODO Auto-generated catch blocke.pr。

17、intStackTrace();如果需要将下面update及insert作为一个事务来整体提交,请问下面代码如果改?public class trans3 /* param args*/public static void main(String args) Connection conn1=null;Connection conn2=null;Statement stmn1=null;Statement stmn2=null;try conn1=connectionFactory.getConnection();conn2=connectionFactory.getConnection();。

18、stmn1=conn1.createStatement();stmn1.executeUpdate(update 账户表 set 金额=金额+5 where 账户名=张三);System.out.println(update语句执行);stmn2=conn2.createStatement();stmn2.executeUpdate(INSERT INTO 账户表 VALUES (张三, 500);System.out.println(insert语句执行); catch (SQLException e) / TODO Auto-generated catch blocke.printStac。

19、kTrace();finallyif(stmn1!=null)try stmn1.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();if(stmn2!=null)try stmn1.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();if(conn1!=null)try conn1.close(); catch (SQLException e) / TODO 。

20、Auto-generated catch blocke.printStackTrace();已知有线程类定义如下:import java.sql.Connection;import java.sql.SQLException;import java.sql.Statement;import java.util.Date;public class clientThread extends Threadprivate String sql=null;private int wait=4000;public String getSql() return sql;public void setSql(。

21、String sql) this.sql = sql;public int getWait() return wait;public void setWait(int wait) this.wait = wait;public void run()Connection conn= connectionFactory.getConnection();try conn.setAutoCommit(false);Statement stmn=conn.createStatement();stmn.executeUpdate(sql);System.out.println(new Date().toS。

22、tring()+ 执行 +sql);this.sleep(wait);conn.commit();System.out.println(线程结束+(new Date().toString(); catch (Exception e) / TODO Auto-generated catch blocke.printStackTrace();有两个测试类client1.javapublic class client1 /* param args*/public static void main(String args) clientThread client=new clientThread();。

23、client.setWait(10000);client.setSql(update 宿舍表 set 姓名=姓名+1 where 床铺=1);client.start();public class client2 /* param args*/public static void main(String args) clientThread client=new clientThread();client.setWait(6000);client.setSql(update 宿舍表 set 姓名=姓名+A where 床铺=1);client.start();请先执行client1然后马上执行。

24、client2,等所有程序,数据库中床铺=1的记录内容是什么?为什么会这样?实验报告(二)院系:信息学院 课程名称:Web数据库技术 日期:班 级A1321姓 名黄伟峰专 业信息管理与信息系统学 号实 验 室实验名称Servlet应用成 绩 评 定教 师 签 名实验目的1、 掌握servlet的配置方法2、 掌握web服务器的配置过程3、 掌握HttpServlet类的用法4、 掌握session等对象的用法5、 掌握请求转发功能的应用6、掌握SerlvetConfig上下文的用法实验内容Servlet配置、servlet设计、会话管理、请求流转、上下文应用1、 请建立一个servlet类用于。

25、显示当前的系统时间。写出它的url配置写法20分。答案:public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException response.setContentType(text/html);PrintWriter out = response.getWriter();out.println();out.println();out.println( A Servlet);out.println( );out.println( );Dat。

26、e date = new Date() ;out.print(date.toLocaleString() ;out.println( );out.println( );out.println();out.flush();out.close();url配置写法:生成servlt时将工程名去掉,只保留文件名,便于访问2、领会多用户并发访问的机制,请建立一个HttpServlet“servletUsers”类,在该类的成员代码如下:public class serveltUsers extends HttpServlet private Integer x=1;public void doGet(H。

27、ttpServletRequest request, HttpServletResponse response)throws ServletException, IOException this.doPost(request, response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException response.setContentType(text/html);response.setCharacterEncodin。

28、g(utf-8);PrintWriter out = response.getWriter();out.println();out.println();out.println( A Servlet);out.println( );out.println(当前x的值是+x);out.flush();synchronized (x) x+;Thread thread=Thread.currentThread();try thread.sleep(1000*5); catch (InterruptedException e) / TODO Auto-generated catch blocke.pr。

29、intStackTrace();out.println(当前serlvet实例阻塞5秒后,当前x的值是+x);out.println( );out.println();out.flush();out.close();请在5秒内用两个浏览器窗口浏览该HttpServlet类,看看效果如何。为什么是这个效果!20分。答:效果是当第一个界面还未刷新,第二个界面无法看到效果。原因是:在全局变量x上加了锁,保证了同一时间,只有一个浏览器才能获得x当前值3、 请设计一个servlet,当连续三次访问该servlet是分别向客户输出:第1次: 用户浏览器中显示:蓝色颜色的 “联系访问中的第1次”第2次: 用。

30、户浏览器中显示:红色颜色的 “联系访问中的第2次”第3次: 用户浏览器中显示:黑色颜色的 “联系访问中的第3次”public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException this.doPost(request, response) ;public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException,。

31、 IOException request.setCharacterEncoding(utf-8) ;response.setCharacterEncoding(utf-8) ;response.setContentType(text/html);PrintWriter out = response.getWriter();out.println();out.println();out.println( A Servlet);out.println( );out.print( );x+ ;/蓝色 0,0,255 红色:rgb(255,0,0) 黑色:rgb(0,0,0)if (x=1) out.。

32、print();else if (x=2) out.print();else if (x=3) out.print();x = 0 ;out.print(第+x+次:);out.print(“连续访问中的第+x+次”);out.print( );out.print( );out.print( );out.println();out.flush();out.close();4、 请将提供的servelt.rar工程解压后添加到myeclipse工作区中,打开mysql将工程中的db目录下的”学生库.sql”导入到mysql数据库中。在工程的serviceDao包中有一个studentServic。

33、esDao,请根据代码中注释的功能结合jdbc中dao模式的设计要求将public student login(String stuId,String name)throws myExceptionstudent stu = new student() ;if(stuId!=null&!.equals(stuId)&name!=null&!.equals(name)return null ;else Connection conn=null;try conn=connectionFactory.getConnection();String sql=select * from 学生基本情况表 w。

34、here 学号 =+stuId+ and 姓名=+name+;Statement stat=conn.createStatement();ResultSet rs=stat.executeQuery(sql);stu.setName(name) ;conn.commit();connectionFactory.closeAll(rs, stat, conn); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();return stu ; 补充完整。20分。5、 现在在webroot下有index。

35、.jsp用来展现学生的登录,现在要求学生输入学号、姓名后交给login这个servlet去处理,login的功能要求如下:(1) 判断用户输入的学号和姓名在学生基本表中是否存在,如果存在提前该学生信息,并将这个学生信息交给另外一个servlet-“dispStudent”去显示。(2) 如果用户输入的学号和姓名在学生基本表中不存在,就直接给用户反馈”找不到输入姓名的学生”。DispStudent这个servlet的功能:显示请求转发过来的学生所有信息。1)public class login extends HttpServlet public void doGet(HttpServletRe。

36、quest request, HttpServletResponse response)throws ServletException, IOException doPost(request, response) ;public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException request.setCharacterEncoding(utf-8) ;response.setCharacterEncoding(utf-8) ;resp。

37、onse.setContentType(text/html;charset=utf-8);PrintWriter out = response.getWriter();boolean isOk = false;String name=request.getParameter(name);String stuId=request.getParameter(stuId);if(name=null|.equals(name)|stuId=null|.equals(stuId)out.print(用户名或者密码为空) ;elseConnection conn = null ;try conn = co。

38、nnectionFactory.getConnection() ;String sql = select * from 学生基本情况表 where 姓名 =+name+ and 学号=+stuId+ ;Statement stat = conn.createStatement() ;ResultSet rs = stat.executeQuery(sql) ;if (rs.next() isOk = true ; conn.commit() ;connectionFactory.closeAll(rs, stat, conn ,null) ; catch (SQLException e) / 。

39、TODO Auto-generated catch blocke.printStackTrace();if(isOk=true)request.setAttribute(stuname,name);request.getRequestDispatcher(/DispStudent).forward(request, response); elseout.print(用户名或者密码错误) ; / response.sendRedirect(index.jsp); 2)public class DispStudent extends HttpServlet public void doGet(Ht。

40、tpServletRequest request, HttpServletResponse response)throws ServletException, IOException this.doPost(request, response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException response.setContentType(text/html;charset=utf-8);/String classNa。

41、me=request.getParameter(stuId).substring(0,5);String stuname=(String)request.getAttribute(stuname);student stu=null;Connection conn=null;try conn=connectionFactory.getConnection();String sql=select * from 学生基本情况表 where 姓名 like +stuname+;Statement stat=conn.createStatement();ResultSet rs=stat.execute。

42、Query(sql);System.out.println(rs.toString();while(rs.next()stu=new student();stu.setId(rs.getInt(id);stu.setStuId(rs.getString(学号);stu.setPro(rs.getString(专业名称);stu.setName(rs.getString(姓名);stu.setSex(rs.getString(性别);conn.commit();connectionFactory.closeAll(rs, null, conn, null); catch (SQLExceptio。

43、n e) / TODO Auto-generated catch blocke.printStackTrace();PrintWriter out = response.getWriter();out.println();out.println();out.println( A Servlet);out.println( id学号姓名专业名称性别);out.print(+stu.getId()+stu.getStuId()+stu.getName()+stu.getPro()+stu.getSex()+);out.println( );out.println();out.flush();out。

44、.close();6、 用户访问统计,当用户首次访问某个servlet时,该servlet的访问总次数加1,如果该用户已经访问了该servlet,再访问时不加1,要求该统计次数能在其他servlet中被调用。/统计访问次数public int cisu(HttpServletRequest request, HttpServletResponse response,String name) throws Exception /判断是否是同一个用户Cookie cookies = request.getCookies() ;for (int i = 0; cookies!=null&i cook。

45、ies.length; i+) if (cookiesi.getName().equals(name) if (!URLDecoder.decode(cookiesi.getValue(), UTF-8).equals(name) x+ ;/用户再次访问Cookie cookie = new Cookie(name,URLEncoder.encode(name, UTF-8) ;cookie.setMaxAge(24*3600) ;cookie.setPath(/servelt) ;response.addCookie(cookie) ;return x ;7、 cookie使用,当用户输入用。

46、户名是张三,密码是1234时,请在servlet中创建一个有效时间是300秒的cookie对象,并回传到用户浏览器,浏览器再访问另外一个servlet,查看该cookie是否存在。保存用户名和密码if (name.equals(张三)& stuId.equals(1234) String name1 = URLEncoder.encode(name, UTF-8);Cookie cookie = new Cookie(name, name1) ;cookie.setMaxAge(300) ; cookie.setPath(/servelt) ;response.addCookie(cookie。

47、) ;String stuId1 = URLEncoder.encode(stuId, UTF-8);Cookie cookie2 = new Cookie(stuId, stuId1) ;cookie2.setMaxAge(300) ;cookie2.setPath(/servelt) ;response.addCookie(cookie2) ;获取用户名和密码public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException requ。

48、est.setCharacterEncoding(utf-8);response.setCharacterEncoding(utf-8);response.setContentType(text/html);PrintWriter out = response.getWriter() ;Cookie cookie = request.getCookies() ;for (int i = 0;cookie!=null& i cookie.length; i+) if (cookiei.getName().equals(name) String name = URLDecoder.decode(c。

49、ookiei.getValue(), UTF-8);out.println(用户名:+name) ;if (cookiei.getName().equals(stuId) String stuId = URLDecoder.decode(cookiei.getValue(), UTF-8);out.println(密码:+stuId) ;8、请设计一种过滤器实现权限控制机制。如果用户进入web应用没有登入时,要求用户必须进入登入页面。20分public class loginFiler implements Filter public void init(FilterConfig filter。

50、Config) throws ServletException / TODO Auto-generated method stubpublic void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException / 获得在下面代码中要用的request,response,session对象HttpServletRequest servletRequest = (HttpServletRequest) request;HttpServletResponse servletResponse = (HttpServletResponse) response。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
建立环境实验数据库/ 实验学时:2学时 实验类型:验证 实验要求:必修 一、实验目的 通过本实验的学习,使学生熟悉SQL Server 2014的集成环境,帮助学生掌握数据库建立方法以及SQL Server的数据导入方法 二、实验内容    (一)、SQL Server 2014的安装 SQL Server2014的安装过程与 SQL Server 2008、SQL Server2012的安装过程类似,都提供了一个功能树以用来安装所有 SQL Server 组件,包括计划、安装、维护、工具、资源、高级、选项等功能。下面是各功能选项中所包含的内容,如图3-1所示。 图3-1 安装计划中的内容 (1)选择“安装”功能,因为要创建SQL Server 2014的全新安装,单击“全新SQL Server 2014独立安装或向现有安装添加功能”选项,如图3-2所示。 图3-2 “安装”功能中的内容 (2)在“产品密匙”页上,选择相应的单选按钮,这些按钮指示是安装免费本的SQL Server还是具有产品密匙的产品本,如果使指免费的评估,只有180天的试用期限,如图3-3所示。 图3-3 “产品密钥”界面 (3)在“许可条款”页上阅读许可协议,然后选中相应的复选框以接受许可条款和条件。如图3-4所示。 图3-4 “许可条款”界面 (4)系统进行安装程序支持规则检查,以确定安装SQL Server安装程序支持文件时可能发生的问题。必须更正所有的失败,安装程序才能继续。如图3-5所示。 图3-5 “安装规则”界面 (5)在“设置角色”页上选择SQL Server功能安装,如图3-6所示。 图3-6 “设置”角色界面 (6)在“功能选择”页上选择要安装的组件。选择功能名称后,右侧窗体中会显示每个组件的说明。可以根据实际需要,选中一些功能,如图3-7所示。一般应用可选择“数据库引擎服务”、“客户端工具连接”、“SQL客户端连接”和“管理工具”等选项。 图3-7“功能选择”界面 (7)在“实例配置”页上制定是安装默认实例还是命名实例,对于默认实例,实例的名称和ID都是MSSQLSERVER,也可以自己“命名实例”安装实例,如图3-8所示。SQL Server支持多个实例,即支持在同一台计算机上同时运行多个SQL Server数据库引擎实例,每个SQL Server数据库引擎实例各有一套不为其它实例共享的系统及用户数据库。应用程序连接同一台计算机上的SQL Server数据库引擎实例的方式与连接其它计算机上运行的SQL Server数据库引擎的方式基本相同。 图3-8 “实例配置”界面 (8)在“服务器配置”页上指定SQL Server服务的登录帐户。SQL Server提供了多种服务,可以为所有SQL Server服务分配相同的登录账户,也可以分别配置每个服务账户。还可以指定服务是自动启动、手动启动还是禁用。Microsoft建议对各服务账户进行单独配置,以便为每项服务提供最低特权,即向SQL Server服务授予它们完成各自任务所需的最低权限,如图3-9所示。SQL Server中的每个服务代一个进程或一组进程,每个进程需要有访问SQL Server相关文件和系统注册的权限,为了能让SQL Server服务在操作系统中正常的启动和运行,就需要指定SQL Server的服务帐户,所以服务帐户指的是Windows操作系统中的帐户。 图3-9 “服务器配置”界面 (9)在“数据库引擎配置”的“服务器配置”页上指定身份验证模式、用户名、密码,如图3-10所示。这里的用户身份验证指的是登录到服务器使用的身份验证模式及用户名和密码。身份验证模式分为“Windows身份验证模式”和“混合模式(SQL Server身份验证和Windows身份验证)”。如果选择“Windows身份验证模式”示则只能使用Windows的帐号登录,即使用当前登录到操作系统的帐号进行登录,通过这种方式用户登录到SQL Server中时不再需要输入帐号和密码。如选择“混合模式(SQL Server身份验证和Windows身份验证)”示除了可以用使用登录到Windows的帐号作为登录的依据外,还可以使用SQL Server系统的帐号登录,这里必须为内置SQL Server系统管理员账户(SA)提供一个强密码。必须至少为SQL Server实例指定一个系统管理员。若要添加用以运行SQL Server安装程序账户,则要单击“添加当前用户”按钮。若要向系统管理员列中添加账户或从中删除账户,则单击“添加…”或“删除…”按钮,然后编辑将拥有SQL Server实例的管理员特权的用户、组或计算机列。 图3-10 设置身份验证模式和管理员 (10)在“准备安装”页显示安装过程中的安装选项的树视图,如图3-11所示。若要继续,单击“安装”按钮。在安装过程中,“安装进度”页会提供相应的状态,因此可以在安装过程中监视安装进度。 图3-121“准备安装”界面 (11)安装完成后,“完成”页提供指向安装日志文件摘要以及其他重要说明的链接。如图3-12所示。 图3-12 “安装完成”界面 (二)、建库建练习      1、利用语句建库和建: 创建学生数据库StuDB,文件名和位置自定,在此数据库中创建如下三张学生(student) (   学号(sno) 普通编码定长字符类型,长度9,主码,   姓名(sname) 普通编码定长字符类型,长度10,非空,   性别(ssex) 统一编码定长字符类型,长度2,   年龄(sage) 微整型,   所在系(sdept) 统一编码可变长字符类型,长度20 ) 课程(course) (   课程号(cno) ,通编码定长字符类型,长度4,主码,   课程名(cname) 统一编码定长字符类型,长度,40,非空,   开课学期(Semester) 短整数, 学分(credit) 短整数 ) 修课(sc)(   学号(sno) 普通编码定长字符类型,长度7,主码,外码   课程号(cno) 普通编码定长字符类型,长度6,主码,外码   成绩(grade) 小整型,   修课类别(ctype)普通编码定长字符类型,长度4 ) 2、建立“汽车”数据库,文件名和位置自定,在此数据库中创建如下三张: 汽车(CarT),结构如下:   汽车序号(CId) 整型 主关键字,   汽车名称(CName) 普通编码定长字符类型 长度为10  非空,   型号(CType)普通编码变长字符类型 长度为60  非空,   价格(CPrice) 整型,   车身眼色(Ccolor)普通编码变长字符类型 长度为20。 部门(DepartT),结构如下:   部门序号(DId)整型 主关键字,   部门名(DName)普通编码定长字符类型 长度为20   非空,   负责人名(DLead)普通编码定长字符类型 长度为10  非空,   人数(DAmount) 整型。 汽车出厂(FacT),结构如下:   汽车序号(CID) 整型 非空,   部门序号(DId) 整型 非空,   出厂日期(FDate)小日期时间型 非空,   出厂数量(FAmount) 整型,   出厂价格(FPrice) 整型。   其中:主关键字为(汽车序号,部门序号,出厂日期)   “汽车序号”为引用汽车的“汽车序号”的外部关键字; “部门序号”为引用部门的“部门序号”的外部关键字。 3、使用数据库的可视化工具建库建 建立银行贷款,具体要求同课堂教学的建库建一致。 银行(BankT)( 银行代码(Bno) 主键 银行名称(Bname) 非空 电话(Tel) ) 法人(LET)( 法人代码(Eno)主键 法人名称(Ename)取值唯一 经济性质(Enature) 注册资金(Ecapital) 法定代人(Erep) ) 贷款(LoanT)( 法人代码(Eno) 银行代码(Bno) 贷款日期(Ldata) 贷款金额(Lamount) 贷款期限(Lterm) )        (三)、数据导入练习 将“学生数据库数据.xls”中的数据导入到学生数据库的三张中。 将“银行贷款数据.xls”中的数据导入到银行贷款数据库的三张中。 三、实验报告实验结果反映在实验报告中,并对实验中遇到的问题及解决方案、进行整理、分析总结,提出实验结论或自己的看法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值