当前位置:   article > 正文

【数据库设计】学籍管理的数据库系统_学籍管理系统数据库设计

学籍管理系统数据库设计

如下代码供学习交流,获取完整代码,请关注文后二维码(coding加油站)回复“数据库学籍管理”免费获取

1、简介

可以用于数据库作业的设计,也可以用于javase作业的设计,数据库为sql server

功能说明:

  1. 简化了数据库的使用者,即没有根据用户名自动切换布局的功能,目标使用者即为管理员
  2. 提供了txt导入学生信息,成绩,课程信息的功能
  3. 提供手动录入学生信息,修改学生信息,批量修改班级及删除学生信息功能
  4. 提供按学号修改成绩及按课程号修改成绩功能
  5. 提供了班级增添,修改,删除,查询功能
  6. 提供了利用班号,学号,姓名,性别查询学生信息及查看学生成绩详情的功能
  7. 提供了按学号查询所有教过课的任课老师姓名
  8. 提供了教学计划修改,查询,统计功能
  9. 提供了自定义查询将被开除学生功能,可以同时设定选修未完成学分限制,必修未完成学分限制及学期必修未完成学分限制,并可查看所有未达标详情
  10. 提供了登陆登出功能,可以利用数据库权限控制指定用户所可拥有的功能

2、项目截图

3、项目代码:

java代码:

  1. package database;
  2. import java.awt.Component;
  3. import java.awt.event.MouseAdapter;
  4. import java.awt.event.MouseEvent;
  5. import javax.swing.JCheckBox;
  6. import javax.swing.JComponent;
  7. import javax.swing.JLabel;
  8. import javax.swing.JTable;
  9. import javax.swing.SwingConstants;
  10. import javax.swing.UIManager;
  11. import javax.swing.table.JTableHeader;
  12. import javax.swing.table.TableCellRenderer;
  13. public class CheckHeaderCellRenderer implements TableCellRenderer {
  14. CheckTableModle tableModel;
  15. JTableHeader tableHeader;
  16. final JCheckBox selectBox;
  17. public CheckHeaderCellRenderer(JTable table) {
  18. this.tableModel = (CheckTableModle)table.getModel();
  19. this.tableHeader = table.getTableHeader();
  20. selectBox = new JCheckBox(tableModel.getColumnName(0));
  21. selectBox.setSelected(false);
  22. tableHeader.addMouseListener(new MouseAdapter() {
  23. public void mouseClicked(MouseEvent e) {
  24. if (e.getClickCount() > 0) {
  25. //获得选中列
  26. int selectColumn = tableHeader.columnAtPoint(e.getPoint());
  27. if (selectColumn == 0) {
  28. boolean value = !selectBox.isSelected();
  29. selectBox.setSelected(value);
  30. tableModel.selectAllOrNull(value);
  31. tableHeader.repaint();
  32. }
  33. }
  34. }
  35. });
  36. }
  37. @Override
  38. public Component getTableCellRendererComponent(JTable table, Object value,
  39. boolean isSelected, boolean hasFocus, int row, int column) {
  40. // TODO Auto-generated method stub
  41. String valueStr = (String) value;
  42. JLabel label = new JLabel(valueStr);
  43. label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中
  44. selectBox.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中
  45. selectBox.setBorderPainted(true);
  46. JComponent component = (column == 0) ? selectBox : label;
  47. component.setForeground(tableHeader.getForeground());
  48. component.setBackground(tableHeader.getBackground());
  49. component.setFont(tableHeader.getFont());
  50. component.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
  51. return component;
  52. }
  53. }
  1. package database;
  2. import java.awt.BorderLayout;
  3. import java.awt.EventQueue;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import java.util.Vector;
  7. import javax.swing.JButton;
  8. import javax.swing.JCheckBox;
  9. import javax.swing.JFileChooser;
  10. import javax.swing.JFrame;
  11. import javax.swing.JLabel;
  12. import javax.swing.JOptionPane;
  13. import javax.swing.JPanel;
  14. import javax.swing.JScrollPane;
  15. import javax.swing.JTable;
  16. import javax.swing.JTextField;
  17. import javax.swing.border.EmptyBorder;
  18. import javax.swing.filechooser.FileNameExtensionFilter;
  19. import javax.swing.table.DefaultTableModel;
  20. import javax.swing.table.TableColumn;
  21. public class Course_insert extends JFrame {
  22. private JPanel contentPane;
  23. private JTextField textField;
  24. private JTextField textField_1;
  25. private JCheckBox checkBox_2,checkBox_1,checkBox;
  26. private Vector<Integer> order=new Vector<Integer>();
  27. private final String[] name=new String[]{"课程号","课程名","学分","课程类型"};
  28. private JPanel panel;
  29. /**
  30. * Launch the application.
  31. */
  32. public static void main(String[] args) {
  33. EventQueue.invokeLater(new Runnable() {
  34. public void run() {
  35. try {
  36. Sql_connetcton.login_s("admin", "admin");
  37. Course_insert frame = new Course_insert();
  38. frame.setVisible(true);
  39. } catch (Exception e) {
  40. e.printStackTrace();
  41. }
  42. }
  43. });
  44. }
  45. /**
  46. * Create the frame.
  47. */
  48. public Course_insert() {
  49. setTitle("\u8BFE\u7A0B\u4FE1\u606F\u5BFC\u5165");
  50. setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  51. setBounds(100, 100, 450, 300);
  52. contentPane = new JPanel();
  53. this.setResizable(false);//居中
  54. this.setLocationRelativeTo(null);
  55. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  56. setContentPane(contentPane);
  57. contentPane.setLayout(null);
  58. ActionListener checkBoxListener=new ActionListener() {
  59. @Override
  60. public void actionPerformed(ActionEvent e) {
  61. String s=textField_1.getText();
  62. if(((JCheckBox)e.getSource()).isSelected()){
  63. s+=e.getActionCommand()+",";
  64. }else{
  65. s=s.replaceAll(e.getActionCommand()+",","");
  66. }
  67. textField_1.setText(s);
  68. }
  69. };
  70. JLabel lblNewLabel = new JLabel("\u5BFC\u5165\u6587\u4EF6:");
  71. lblNewLabel.setBounds(10, 10, 63, 15);
  72. contentPane.add(lblNewLabel);
  73. textField = new JTextField();
  74. textField.setBounds(67, 7, 216, 21);
  75. contentPane.add(textField);
  76. textField.setColumns(10);
  77. JButton button = new JButton("...");
  78. button.addActionListener(new ActionListener() {
  79. public void actionPerformed(ActionEvent e) {
  80. JFileChooser file=new JFileChooser();
  81. file.setAcceptAllFileFilterUsed(false); //关闭所有文件筛选器
  82. file.setMultiSelectionEnabled(false); //关闭多选
  83. file.setFileFilter(new FileNameExtensionFilter("TXT", "txt")); //添加txt筛选器
  84. if(file.showDialog(getParent(), "导入")==JFileChooser.APPROVE_OPTION){
  85. textField.setText(file.getSelectedFile().getPath()); //获得保存路径
  86. }
  87. }
  88. });
  89. button.setBounds(287, 7, 25, 21);
  90. contentPane.add(button);
  91. JButton button_1 = new JButton("\u5BFC\u5165");
  92. button_1.setBounds(379, 6, 63, 23);
  93. contentPane.add(button_1);
  94. JButton button_2 = new JButton("\u9884\u89C8");
  95. button_2.setBounds(315, 6, 63, 23);
  96. contentPane.add(button_2);
  97. JLabel label = new JLabel("\u5BFC\u5165\u683C\u5F0F:");
  98. label.setBounds(10, 38, 87, 15);
  99. contentPane.add(label);
  100. textField_1 = new JTextField();
  101. textField_1.setBounds(67, 35, 216, 21);
  102. contentPane.add(textField_1);
  103. textField_1.setColumns(10);
  104. checkBox = new JCheckBox("\u8BFE\u7A0B\u53F7");
  105. checkBox.setBounds(10, 59, 63, 23);
  106. checkBox.addActionListener(checkBoxListener);
  107. checkBox.addActionListener(new ActionListener() {
  108. @Override
  109. public void actionPerformed(ActionEvent e) {
  110. if(((JCheckBox)e.getSource()).isSelected()){
  111. order.add(new Integer(0));
  112. }else{
  113. order.remove(new Integer(0));
  114. }
  115. }
  116. });
  117. checkBox_2 = new JCheckBox("\u5B66\u5206");
  118. checkBox_2.setBounds(146, 59, 54, 23);
  119. checkBox_2.addActionListener(checkBoxListener);
  120. checkBox_2.addActionListener(new ActionListener() {
  121. @Override
  122. public void actionPerformed(ActionEvent e) {
  123. if(((JCheckBox)e.getSource()).isSelected()){
  124. order.add(new Integer(2));
  125. }else{
  126. order.remove(new Integer(2));
  127. }
  128. }
  129. });
  130. contentPane.add(checkBox_2);
  131. checkBox_1 = new JCheckBox("\u8BFE\u7A0B\u540D");
  132. checkBox_1.setBounds(77, 59, 67, 23);
  133. checkBox_1.addActionListener(checkBoxListener);
  134. checkBox_1.addActionListener(new ActionListener() {
  135. @Override
  136. public void actionPerformed(ActionEvent e) {
  137. if(((JCheckBox)e.getSource()).isSelected()){
  138. order.add(new Integer(1));
  139. }else{
  140. order.remove(new Integer(1));
  141. }
  142. }
  143. });
  144. contentPane.add(checkBox_1);
  145. contentPane.add(checkBox);
  146. final JButton button_3 = new JButton("\u9501\u5B9A");
  147. button_3.addActionListener(new ActionListener() {
  148. public void actionPerformed(ActionEvent e) {
  149. String s=textField_1.getText();
  150. if(e.getActionCommand()=="锁定"){
  151. textField_1.setEnabled(false);
  152. checkBox_2.setEnabled(false);
  153. checkBox_1.setEnabled(false);
  154. checkBox.setEnabled(false);
  155. if(s.endsWith(",")){
  156. textField_1.setText(s.substring(0,s.length()-1));
  157. }
  158. button_3.setText("解锁");
  159. }else{
  160. textField_1.setEnabled(true);
  161. checkBox_2.setEnabled(true);
  162. checkBox_1.setEnabled(true);
  163. checkBox.setEnabled(true);
  164. textField_1.setText(s+",");
  165. button_3.setText("锁定");
  166. }
  167. }
  168. });
  169. button_3.setBounds(287, 34, 63, 23);
  170. contentPane.add(button_3);
  171. panel = new JPanel();
  172. panel.setBounds(10, 88, 424, 173);
  173. contentPane.add(panel);
  174. panel.setLayout(new BorderLayout(0, 0));//保持边距,不然会超出显示区域
  175. final JTable table = new JTable();
  176. panel.removeAll();
  177. JScrollPane sPane=new JScrollPane(table);
  178. sPane.setAutoscrolls(true);
  179. panel.add(sPane,BorderLayout.CENTER);
  180. JCheckBox kind = new JCheckBox("\u8BFE\u7A0B\u7C7B\u578B");
  181. kind.setBounds(202, 59, 103, 23);
  182. contentPane.add(kind);
  183. kind.addActionListener(new ActionListener() {
  184. @Override
  185. public void actionPerformed(ActionEvent e) {
  186. if(((JCheckBox)e.getSource()).isSelected()){
  187. order.add(new Integer(3));
  188. }else{
  189. order.remove(new Integer(3));
  190. }
  191. }
  192. });
  193. kind.addActionListener(checkBoxListener);
  194. button_2.addActionListener(new ActionListener() {
  195. public void actionPerformed(ActionEvent e) {
  196. final Vector<Vector<String>> ans=
  197. file_insert.get(textField_1.getText(), textField.getText(), name, order);
  198. //file_insert.get("","C:\\Users\\jxy1\\Documents\\GitHub\\Database-project\\导入数据\\test.txt",name,order);
  199. final Vector<String> names=new Vector<String>();
  200. for(String s:name)names.add(s);
  201. DefaultTableModel dataModel=new DefaultTableModel(ans,names)
  202. {
  203. @Override
  204. public boolean isCellEditable(int rowIndex, int columnIndex) {
  205. return false;
  206. }
  207. @Override
  208. public Object getValueAt(int rowIndex, int columnIndex) {
  209. if(columnIndex==0){
  210. return rowIndex+1;
  211. }
  212. Vector rowVector = (Vector)dataVector.elementAt(rowIndex);
  213. if(columnIndex==4)
  214. if(rowVector.elementAt(columnIndex-1)=="NULL")
  215. setValueAt("必修", rowIndex, columnIndex-1);
  216. return rowVector.elementAt(columnIndex-1);
  217. }
  218. @Override
  219. public String getColumnName(int columnIndex) {
  220. if(columnIndex==0)return "序号";
  221. return names.get(columnIndex-1);
  222. }
  223. @Override
  224. public int getColumnCount() {
  225. return names.size()+1;
  226. }
  227. };
  228. table.setModel(dataModel);
  229. for(int i=0;i<1;i++){
  230. TableColumn column = table.getColumnModel().getColumn(i);
  231. column.setPreferredWidth(25);
  232. }
  233. }
  234. });
  235. button_1.addActionListener(new ActionListener() {
  236. public void actionPerformed(ActionEvent e) {
  237. DefaultTableModel now=(DefaultTableModel) table.getModel();
  238. int row=now.getRowCount(),col=now.getColumnCount()-1;
  239. int rr=0;
  240. Vector s= now.getDataVector();
  241. for(int i=0;i<row;i++){
  242. Vector<String> temp=(Vector<String>) s.elementAt(rr);
  243. if(temp.size()>col)temp.remove(col);
  244. if(Sql_connetcton.insert(temp,"课程")==true){
  245. now.removeRow(rr);
  246. }else{
  247. rr++;
  248. }
  249. }
  250. JOptionPane.showMessageDialog(null,"成功"+(row-rr)+"个,失败"+rr+"个","导入结果", JOptionPane.INFORMATION_MESSAGE);
  251. }
  252. });
  253. }
  254. }

数据库相关sql:

  1. USE [学籍管理系统]
  2. GO
  3. /****** Object: Table [dbo].[专业] Script Date: 12/18/2021 00:42:01 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE TABLE [dbo].[专业](
  9. [专业号] [int] NOT NULL,
  10. [专业名] [nchar](10) NOT NULL,
  11. [学院名] [nchar](10) NOT NULL,
  12. PRIMARY KEY CLUSTERED
  13. (
  14. [专业号] ASC
  15. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  16. ) ON [PRIMARY]
  17. GO
  18. USE [学籍管理系统]
  19. GO
  20. /****** Object: Table [dbo].[班级] Script Date: 12/18/2021 00:42:08 ******/
  21. SET ANSI_NULLS ON
  22. GO
  23. SET QUOTED_IDENTIFIER ON
  24. GO
  25. CREATE TABLE [dbo].[班级](
  26. [班号] [nchar](6) NOT NULL,
  27. [专业号] [int] NOT NULL,
  28. [班主任] [nchar](10) NOT NULL,
  29. [入学年份] [int] NOT NULL,
  30. CONSTRAINT [PK_班级] PRIMARY KEY CLUSTERED
  31. (
  32. [班号] ASC
  33. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  34. ) ON [PRIMARY]
  35. GO
  36. ALTER TABLE [dbo].[班级] WITH CHECK ADD CONSTRAINT [FK_班级_专业] FOREIGN KEY([专业号])
  37. REFERENCES [dbo].[专业] ([专业号])
  38. GO
  39. ALTER TABLE [dbo].[班级] CHECK CONSTRAINT [FK_班级_专业]
  40. GO
  41. ALTER TABLE [dbo].[班级] WITH CHECK ADD CONSTRAINT [CK_班级] CHECK (([入学年份]>(1800) AND [入学年份]<(10000)))
  42. GO
  43. ALTER TABLE [dbo].[班级] CHECK CONSTRAINT [CK_班级]
  44. GO
  45. USE [学籍管理系统]
  46. GO
  47. /****** Object: Table [dbo].[学生] Script Date: 12/18/2021 00:42:18 ******/
  48. SET ANSI_NULLS ON
  49. GO
  50. SET QUOTED_IDENTIFIER ON
  51. GO
  52. CREATE TABLE [dbo].[学生](
  53. [班号] [nchar](6) NULL,
  54. [学号] [nchar](8) NOT NULL,
  55. [姓名] [nchar](10) NOT NULL,
  56. [性别] [nchar](1) NOT NULL,
  57. [出生日期] [smalldatetime] NULL,
  58. CONSTRAINT [PK_学生] PRIMARY KEY CLUSTERED
  59. (
  60. [学号] ASC
  61. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  62. ) ON [PRIMARY]
  63. GO
  64. ALTER TABLE [dbo].[学生] WITH CHECK ADD CONSTRAINT [FK_学生_班级] FOREIGN KEY([班号])
  65. REFERENCES [dbo].[班级] ([班号])
  66. GO
  67. ALTER TABLE [dbo].[学生] CHECK CONSTRAINT [FK_学生_班级]
  68. GO
  69. ALTER TABLE [dbo].[学生] WITH CHECK ADD CONSTRAINT [CK_学生] CHECK (([性别]=N'女' OR [性别]=N'男'))
  70. GO
  71. ALTER TABLE [dbo].[学生] CHECK CONSTRAINT [CK_学生]
  72. GO
  73. ALTER TABLE [dbo].[学生] ADD CONSTRAINT [DF_学生_性别] DEFAULT (N'男') FOR [性别]
  74. GO
  75. USE [学籍管理系统]
  76. GO
  77. /****** Object: Table [dbo].[课程] Script Date: 12/18/2021 00:42:25 ******/
  78. SET ANSI_NULLS ON
  79. GO
  80. SET QUOTED_IDENTIFIER ON
  81. GO
  82. CREATE TABLE [dbo].[课程](
  83. [课程号] [nchar](9) NOT NULL,
  84. [课程名] [nchar](25) NOT NULL,
  85. [学分] [int] NOT NULL,
  86. [课程类型] [nchar](2) NOT NULL,
  87. CONSTRAINT [PK_课程] PRIMARY KEY CLUSTERED
  88. (
  89. [课程号] ASC
  90. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  91. ) ON [PRIMARY]
  92. GO
  93. ALTER TABLE [dbo].[课程] WITH CHECK ADD CONSTRAINT [CK_课程] CHECK (([课程类型]='任选' OR [课程类型]='限选' OR [课程类型]='必修'))
  94. GO
  95. ALTER TABLE [dbo].[课程] CHECK CONSTRAINT [CK_课程]
  96. GO
  97. ALTER TABLE [dbo].[课程] ADD CONSTRAINT [DF_课程_课程类型] DEFAULT (N'必修') FOR [课程类型]
  98. GO
  99. USE [学籍管理系统]
  100. GO
  101. /****** Object: Table [dbo].[课表] Script Date: 12/18/2021 00:42:30 ******/
  102. SET ANSI_NULLS ON
  103. GO
  104. SET QUOTED_IDENTIFIER ON
  105. GO
  106. CREATE TABLE [dbo].[课表](
  107. [课程号] [nchar](9) NOT NULL,
  108. [班级号] [nchar](6) NOT NULL,
  109. [任课教师] [nchar](10) NOT NULL,
  110. CONSTRAINT [PK_课表] PRIMARY KEY CLUSTERED
  111. (
  112. [任课教师] ASC,
  113. [班级号] ASC
  114. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  115. ) ON [PRIMARY]
  116. GO
  117. ALTER TABLE [dbo].[课表] WITH CHECK ADD CONSTRAINT [FK_课表_班级] FOREIGN KEY([班级号])
  118. REFERENCES [dbo].[班级] ([班号])
  119. GO
  120. ALTER TABLE [dbo].[课表] CHECK CONSTRAINT [FK_课表_班级]
  121. GO
  122. ALTER TABLE [dbo].[课表] WITH CHECK ADD CONSTRAINT [FK_课表_课程] FOREIGN KEY([课程号])
  123. REFERENCES [dbo].[课程] ([课程号])
  124. GO
  125. ALTER TABLE [dbo].[课表] CHECK CONSTRAINT [FK_课表_课程]
  126. GO
  127. USE [学籍管理系统]
  128. GO
  129. /****** Object: Table [dbo].[教学计划] Script Date: 12/18/2021 00:42:50 ******/
  130. SET ANSI_NULLS ON
  131. GO
  132. SET QUOTED_IDENTIFIER ON
  133. GO
  134. CREATE TABLE [dbo].[教学计划](
  135. [学期] [nchar](1) NOT NULL,
  136. [专业号] [int] NOT NULL,
  137. [课程号] [nchar](9) NOT NULL,
  138. CONSTRAINT [PK_教学计划] PRIMARY KEY CLUSTERED
  139. (
  140. [专业号] ASC,
  141. [课程号] ASC
  142. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  143. ) ON [PRIMARY]
  144. GO
  145. ALTER TABLE [dbo].[教学计划] WITH CHECK ADD CONSTRAINT [FK_教学计划_课程] FOREIGN KEY([课程号])
  146. REFERENCES [dbo].[课程] ([课程号])
  147. GO
  148. ALTER TABLE [dbo].[教学计划] CHECK CONSTRAINT [FK_教学计划_课程]
  149. GO
  150. ALTER TABLE [dbo].[教学计划] WITH CHECK ADD CONSTRAINT [FK_教学计划_专业] FOREIGN KEY([专业号])
  151. REFERENCES [dbo].[专业] ([专业号])
  152. GO
  153. ALTER TABLE [dbo].[教学计划] CHECK CONSTRAINT [FK_教学计划_专业]
  154. GO
  155. ALTER TABLE [dbo].[教学计划] WITH CHECK ADD CONSTRAINT [CK_教学计划] CHECK (([学期]>(0) AND [学期]<(9)))
  156. GO
  157. ALTER TABLE [dbo].[教学计划] CHECK CONSTRAINT [CK_教学计划]
  158. GO
  159. USE [学籍管理系统]
  160. GO
  161. /****** Object: Table [dbo].[成绩] Script Date: 12/18/2021 00:42:53 ******/
  162. SET ANSI_NULLS ON
  163. GO
  164. SET QUOTED_IDENTIFIER ON
  165. GO
  166. CREATE TABLE [dbo].[成绩](
  167. [学号] [nchar](8) NOT NULL,
  168. [课程号] [nchar](9) NOT NULL,
  169. [成绩] [int] NULL,
  170. [补考成绩] [int] NULL,
  171. [真实成绩] [int] NULL,
  172. CONSTRAINT [PK_成绩] PRIMARY KEY CLUSTERED
  173. (
  174. [学号] ASC,
  175. [课程号] ASC
  176. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  177. ) ON [PRIMARY]
  178. GO
  179. ALTER TABLE [dbo].[成绩] WITH CHECK ADD CONSTRAINT [FK_成绩_课程] FOREIGN KEY([课程号])
  180. REFERENCES [dbo].[课程] ([课程号])
  181. GO
  182. ALTER TABLE [dbo].[成绩] CHECK CONSTRAINT [FK_成绩_课程]
  183. GO
  184. ALTER TABLE [dbo].[成绩] WITH CHECK ADD CONSTRAINT [FK_成绩_学生] FOREIGN KEY([学号])
  185. REFERENCES [dbo].[学生] ([学号])
  186. GO
  187. ALTER TABLE [dbo].[成绩] CHECK CONSTRAINT [FK_成绩_学生]
  188. GO
  189. ALTER TABLE [dbo].[成绩] WITH CHECK ADD CONSTRAINT [CK_成绩] CHECK (([成绩]>=(0) AND [成绩]<=(100)))
  190. GO
  191. ALTER TABLE [dbo].[成绩] CHECK CONSTRAINT [CK_成绩]
  192. GO
  193. ALTER TABLE [dbo].[成绩] WITH CHECK ADD CONSTRAINT [CK_成绩_t] CHECK (([补考成绩] IS NULL OR [成绩] IS NOT NULL AND [补考成绩]>=(0) AND [补考成绩]<=(100) AND [成绩]<(60)))
  194. GO
  195. ALTER TABLE [dbo].[成绩] CHECK CONSTRAINT [CK_成绩_t]
  196. GO

如下代码供学习交流,获取完整代码,请关注文后二维码(coding加油站)回复“数据库学籍管理”免费获取

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/745725
推荐阅读
相关标签
  

闽ICP备14008679号