具有多种数据类型的表的ID

时间:2017-06-25 07:26:42

标签: mysql sql sql-server

我有一个小问题,如果我有一个名为import java.awt.Color; import java.awt.EventQueue; import java.awt.Font; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.SpringLayout; import javax.swing.border.BevelBorder; import javax.swing.border.EmptyBorder; import javax.swing.border.EtchedBorder; public class Test extends JFrame { private JPanel contentPane; public static void main(String[] args) { Test frame = new Test(); frame.setVisible(true); } /** * Create the frame. */ public Test() { setTitle("Test Program"); setResizable(false); setBackground(Color.WHITE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 871, 630); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); SpringLayout sl_contentPane = new SpringLayout(); contentPane.setLayout(sl_contentPane); JPanel panel = new JPanel(); sl_contentPane.putConstraint(SpringLayout.NORTH, panel, 5, SpringLayout.NORTH, contentPane); sl_contentPane.putConstraint(SpringLayout.WEST, panel, 5, SpringLayout.WEST, contentPane); sl_contentPane.putConstraint(SpringLayout.SOUTH, panel, 578, SpringLayout.NORTH, contentPane); sl_contentPane.putConstraint(SpringLayout.EAST, panel, 291, SpringLayout.WEST, contentPane); panel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null)); contentPane.add(panel); SpringLayout sl_panel = new SpringLayout(); panel.setLayout(sl_panel); JPanel panel_1 = new JPanel(); sl_panel.putConstraint(SpringLayout.NORTH, panel_1, 53, SpringLayout.NORTH, panel); sl_panel.putConstraint(SpringLayout.WEST, panel_1, 12, SpringLayout.WEST, panel); sl_panel.putConstraint(SpringLayout.SOUTH, panel_1, 537, SpringLayout.NORTH, panel); sl_panel.putConstraint(SpringLayout.EAST, panel_1, 274, SpringLayout.WEST, panel); panel_1.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null)); panel.add(panel_1); SpringLayout sl_panel_1 = new SpringLayout(); panel_1.setLayout(sl_panel_1); JSeparator separator = new JSeparator(); sl_panel_1.putConstraint(SpringLayout.NORTH, separator, 54, SpringLayout.NORTH, panel_1); sl_panel_1.putConstraint(SpringLayout.WEST, separator, 12, SpringLayout.WEST, panel_1); sl_panel_1.putConstraint(SpringLayout.SOUTH, separator, 69, SpringLayout.NORTH, panel_1); sl_panel_1.putConstraint(SpringLayout.EAST, separator, 250, SpringLayout.WEST, panel_1); panel_1.add(separator); JLabel lblNewLabel = new JLabel("Results:"); sl_panel_1.putConstraint(SpringLayout.NORTH, lblNewLabel, 13, SpringLayout.NORTH, panel_1); sl_panel_1.putConstraint(SpringLayout.WEST, lblNewLabel, 12, SpringLayout.WEST, panel_1); sl_panel_1.putConstraint(SpringLayout.SOUTH, lblNewLabel, 55, SpringLayout.NORTH, panel_1); sl_panel_1.putConstraint(SpringLayout.EAST, lblNewLabel, 115, SpringLayout.WEST, panel_1); lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 21)); panel_1.add(lblNewLabel); JPanel panel_2 = new JPanel(); panel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); sl_panel_1.putConstraint(SpringLayout.NORTH, panel_2, -2, SpringLayout.SOUTH, separator); sl_panel_1.putConstraint(SpringLayout.WEST, panel_2, 2, SpringLayout.WEST, lblNewLabel); sl_panel_1.putConstraint(SpringLayout.SOUTH, panel_2, 398, SpringLayout.SOUTH, separator); sl_panel_1.putConstraint(SpringLayout.EAST, panel_2, 0, SpringLayout.EAST, separator); panel_2.setLayout(new BoxLayout(panel_2, BoxLayout.Y_AXIS)); for(int i = 0; i < 50; i++) { JButton bttn = new JButton("TEST"); panel_2.add(bttn); } JScrollPane scrollPane = new JScrollPane(panel_2); sl_panel_1.putConstraint(SpringLayout.NORTH, scrollPane, 0, SpringLayout.NORTH, panel_1); sl_panel_1.putConstraint(SpringLayout.WEST, scrollPane, 0, SpringLayout.WEST, panel_1); sl_panel_1.putConstraint(SpringLayout.SOUTH, scrollPane, 0, SpringLayout.NORTH, panel_1); sl_panel_1.putConstraint(SpringLayout.EAST, scrollPane, 0, SpringLayout.WEST, panel_1); panel_1.add(scrollPane); //panel_1.add(panel_2); if this is used instead of the above 6 lines of scrollPane, then the buttons appear } } 的表,其中包含电子邮件用户信息,每个人怎么办?电子邮件有多个问题和答案?我是否创建了第二个包含秘密问题和答案的表格,并使用emails将它们与每封电子邮件相关联?如果是,请将它们与每个Foreign keyemail_name相关联吗?

如果是后者,在插入时,我是否必须先插入电子邮件,然后在id中再次插入secret table / email_name?< / p>

示例:

id

1 个答案:

答案 0 :(得分:1)

我更愿意为问题和答案创建一个单独的表格。并在primary key表中将emailid foreign keyquestions用作id

分别在primary keyforeign key表中使用emailid作为questionsid,因为emailid是数字,并且将存储更少的内存比较到BitmapFont列。