Hi, muss ich bei einem Attribut schreiben, dass er ein foreign key ist in sql, wenn ich refernces mache und dann ein primery key referenziere? Dann braucht man nicht extra foreign key schreiben oder? Ist automatisch schon ein primary key dann?
Ne ich mein z. B.:wenn du primary key auf primary key hast hast du ne 1:1 beziehung die kannst du auch zusammen fügen
try (Statement op = connection.createStatement()) {
String m = "CREATE TABLE IF NOT EXISTS abc" +
"(ad INTEGER PRIMARY KEY,"+
op.executeUpdate(m);
op.close();
} catch (SQLException e) {
e.printStackTrace();
}
try (Statement st = connection.createStatement()) {
String u= "CREATE TABLE IF NOT EXISTS abcd" +
"(ID INTEGER PRIMARY KEY," +
"oki INTEGER REFERENCES Hochschulen(ad)),"
st.executeUpdate(u);
st.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}