· 4 years ago · Jun 06, 2021, 10:08 AM
1package CopounDB;
2
3public class ForeignKey {
4 final static String fKey = "" +
5 " CREATE TABLE IF NOT EXISTS `customers_vs_coupons (" +
6 " `cutomer_id` INT NOT NULL," +
7 " `coupon_id` INT NOT NULL," +
8 " PRIMARY KEY(`customer_id`,`coupon_id`)," +
9 " INDEX `coupon_id_idx` (`coupon_id` ASC) VISIBLE," +
10 "" +
11 " FOREIGN KEY(`customer_id`)" +
12 " REFERENCES `customers` (`id`)," +
13 "" +
14 "" +
15 "" +
16 " FOREIGN KEY(`coupon_id`)" +
17 " REFERENCES `coupons` (`id`)," +
18 "" +
19 ")";
20
21 final static String fromWorkBench = "\"" +
22 "CREATE TABLE `customer_vs_coupon` (\n" +
23 " `customer_id` int(11) NOT NULL,\n" +
24 " `coupon_id` int(11) NOT NULL,\n" +
25 " PRIMARY KEY (`customer_id`,`coupon_id`)\n" +
26 ")";
27}
28