Skip to content

database structure access

Fabian Wurm edited this page Mar 22, 2018 · 1 revision

Datenbankstruktur und Zugriff

Zugriff über H2Handler

Um über den H2Handler auf die Datenbank zugreifen zu können muss folgendes beachtet werden:

  • Der H2Handler versucht sich auf eine Datenbank mit dem Namen "fotostudio", mit dem Benutzer "sa" und einem leeren Passwort "" anzumelden. Diese Datenbank muss schon erstellt worden sein bevor der H2Handler genutzt werden kann. Dazu beim Verbinden zur Datenbank über das Web-Interface von H2 den neuen Datenbanknamen in die JDBC-URL einfügen und aufrufen, dann wird sie automatisch erstellt.
  • Das DBHandler Interface ist zu verwenden. Keine Variable soll als H2Handler deklariert sein.
  • Der H2Handler ist als Singleton implementiert.
  • Die Implementierung von H2Handler liefert auf getConnection() immer die selbe Connection-Instanz zurück. Das heißt auch, dass diese Connection niemals außerhalb des Handlers geschlossen werden darf, sondern nur über die closeConnection() Funktion im Handler.

Die in den Beispiel-Daten aus dem Insert-Script enthaltenen User-Credentials sind: Adminname: admin Passwort: martin

Datenbank - aktuelle Version (06.01.2017)

Sequences

Wir verfügen über 8 Sequences, allesamt für die Vergabe von IDs für andere Tabellen. Sie alle sind begrenzt auf den Wert 2147483600, der knapp unter Int.MAX_VALUE liegt, somit kann innerhalb der Anwendung trotzdem Datentyp int für IDs verwendet werden, trotz Datentyp BIGINT in der Datenbank. Ist der Maximalwert einer Sequence erreicht wird wieder bei 1 begonnen.

Name Zugehörige Tabelle
profiles_seq profiles
shootings_seq shootings
images_seq images
positions_seq positions
cameras_seq cameras
logos_seq logos
profile_logo_relativeRectangles_seq profile_logo_relativeRectangles
profile_camera_positions_seq profile_camera_positions

adminusers

Attribute Datatype Properties References
adminname VARCHAR(20) PRIMARY KEY -
password BINARY(32) NOT NULL -

profiles

Attribute Datatype Properties References
profileID BIGINT DEFAULT profiles_seq.nextval PRIMARY KEY -
name VARCHAR(50) NOT NULL -
isMobilEnabled BOOLEAN DEFAULT FALSE -
isPrintEnabled BOOLEAN DEFAULT FALSE -
isFilterEnabled BOOLEAN DEFAULT FALSE -
isGreenscreenEnabled BOOLEAN DEFAULT FALSE -
watermark VARCHAR(250) NOT NULL DEFAULT '' -
isDeleted BOOLEAN DEFAULT FALSE -

shootings

Attribute Datatype Properties References
shootingID BIGINT DEFAULT shootings_seq.nextval PRIMARY KEY -
profileID BIGINT ON DELETE SET NULL profiles(profileID)
folderpath VARCHAR(250) NOT NULL -
isActive BOOLEAN DEFAULT true -

images

Attribute Datatype Properties References
imageID BIGINT DEFAULT images_seq.nextval PRIMARY KEY -
imagepath VARCHAR(250) NOT NULL -
shootingID BIGINT NOT NULL ON DELETE CASCADE ON UPDATE CASCADE shootings(shootingID)
time TIMESTAMP - -

positions

Attribute Datatype Properties References
positionID BIGINT DEFAULT positions_seq.nextval PRIMARY KEY -
name VARCHAR(50) NOT NULL -
buttonImagePath VARCHAR(250) NOT NULL -
isDeleted BOOLEAN DEFAULT false -

cameras

Attribute Datatype Properties References
cameraID BIGINT DEFAULT cameras_seq.nextval PRIMARY KEY -
label VARCHAR(50) NOT NULL -
modelName VARCHAR(50) NOT NULL -
portNumber VARCHAR(50) NOT NULL -
serialNumber VARCHAR(50) NOT NULL -
isActive BOOLEAN DEFAULT false -

profile_camera_positions

Attribute Datatype Properties References
profile_camera_positions_id BIGINT DEFAULT profile_camera_positions_seq.nextval PRIMARY KEY -
profileId BIGINT ON DELETE CASCADE profiles(profileID)
cameraId BIGINT ON DELETE CASCADE cameras(cameraId)
positionId BIGINT ON DELETE CASCADE positions(positionID)
isGreenscreenReady BOOLEAN DEFAULT false -

UNIQUE KEY (profileId, cameraId) UNIQUE KEY (profileId, cameraId, positionID)

logos

Attribute Datatype Properties References
logoID BIGINT DEFAULT logos_seq.nextval PRIMARY KEY -
label VARCHAR(50) NOT NULL -
path VARCHAR(250) NOT NULL DEFAULT '' -
isDeleted BOOLEAN DEFAULT false -

profile_logo_relativeRectangles

Attribute Datatype Properties References
profile_logo_relativeRectangles_id BIGINT DEFAULT profile_logo_relativeRectangles_seq.nextval PRIMARY KEY -
profileId BIGINT ON DELETE CASCADE profiles(profileID)
logoId BIGINT ON DELETE CASCADE logos(logoId)
x DOUBLE - -
y DOUBLE - -
width DOUBLE - -
height DOUBLE - -

UNIQUE KEY (profile_logo_relativeRectangles_id,profileId, logoId)

Datenbank - vorige Version (27.11.2016)

adminusers

Attribute Datatype Properties References
adminname VARCHAR(20) PRIMARY KEY -
password BINARY(32) NOT NULL -

profiles

Attribute Datatype Properties References
profileID INT AUTO_INCREMENT PRIMARY KEY -
name VARCHAR(50) NOT NULL -
isActive BOOLEAN DEFAULT FALSE -

shootings

Attribute Datatype Properties References
shootingID INT AUTO_INCREMENT PRIMARY KEY -
profileID INT ON DELETE SET NULL profiles(profileID)
folderpath VARCHAR(250) NOT NULL -
isActive BOOLEAN DEFAULT true -

images

Attribute Datatype Properties References
imageID INT PRIMARY KEY -
imagepath VARCHAR(250) NOT NULL -
shootingID INT ON DELETE SET NULL shootings(shootingID)
time TIMESTAMP - -