diff --git a/ws/eclipse/Company/.gitignore b/ws/eclipse/Company/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..9683914227e45494030a520ec58b6508a4b65c0f --- /dev/null +++ b/ws/eclipse/Company/.gitignore @@ -0,0 +1,4 @@ +/target +.classpath +.project +.settings \ No newline at end of file diff --git a/ws/eclipse/Company/Sql/200/deptCascade b/ws/eclipse/Company/Sql/200/deptCascade new file mode 100644 index 0000000000000000000000000000000000000000..6d75a53984bf6086aed4617753a4f41d83a2b033 --- /dev/null +++ b/ws/eclipse/Company/Sql/200/deptCascade @@ -0,0 +1,18 @@ +drop table if exists Employee; +drop table if exists Department; + +CREATE TABLE Department( + id BIGINT PRIMARY KEY + ,name CHAR(20) NOT NULL UNIQUE +); + +CREATE TABLE Employee ( + id BIGINT PRIMARY KEY + ,number INTEGER NOT NULL UNIQUE + ,name CHAR(20) NOT NULL + ,surname CHAR(20) NOT NULL + ,department CHAR(20) NOT NULL REFERENCES Department(name) + ON UPDATE CASCADE + ,telephone CHAR(4) NOT NULL + ,fax CHAR(4) +); \ No newline at end of file diff --git a/ws/eclipse/Company/Sql/200/schema.sql b/ws/eclipse/Company/Sql/200/schema.sql new file mode 100644 index 0000000000000000000000000000000000000000..fe4a1282b0ffe81cc89b43abac13ba7d65b63fb9 --- /dev/null +++ b/ws/eclipse/Company/Sql/200/schema.sql @@ -0,0 +1,35 @@ +drop table if exists Employee; +drop table if exists Project; +drop table if exists Department; +drop table if exists EmployeeProject; + +CREATE TABLE Department( + id BIGINT PRIMARY KEY + ,number INTEGER NOT NULL UNIQUE + ,name CHAR(20) NOT NULL UNIQUE +); + +CREATE TABLE Employee ( + id BIGINT PRIMARY KEY + ,number INTEGER NOT NULL UNIQUE + ,name CHAR(20) NOT NULL + ,surname CHAR(20) NOT NULL + ,department BIGINT NOT NULL REFERENCES Department + ,telephone CHAR(4) NOT NULL + ,fax CHAR(4) +); + +CREATE TABLE Project ( + id BIGINT PRIMARY KEY + ,number INTEGER NOT NULL UNIQUE + ,name CHAR(20) NOT NULL UNIQUE + ,status SMALLINT NOT NULL + ,CHECK (status IN (1,2,3,3)) -- planned, active, on hold, finished -- +); + +CREATE TABLE EmployeeProject ( + employee BIGINT NOT NULL REFERENCES Employee + ,project BIGINT NOT NULL REFERENCES Project + ,PRIMARY KEY(employee, project) + ,weeklyHours INTEGER NOT NULL +) \ No newline at end of file diff --git a/ws/eclipse/Company/Sql/Final/data.sql b/ws/eclipse/Company/Sql/Final/data.sql new file mode 100644 index 0000000000000000000000000000000000000000..120de18e26b610c0f4785cf6df0de0c426233136 --- /dev/null +++ b/ws/eclipse/Company/Sql/Final/data.sql @@ -0,0 +1,2 @@ +INSERT INTO Department VALUES(1, 12, "Sales", NULL); + diff --git a/ws/eclipse/Company/Sql/Final/deptCascade b/ws/eclipse/Company/Sql/Final/deptCascade new file mode 100644 index 0000000000000000000000000000000000000000..0749ece5dcd428fb294ecefef6f1b7427da97323 --- /dev/null +++ b/ws/eclipse/Company/Sql/Final/deptCascade @@ -0,0 +1,11 @@ +drop table if exists Department; + +CREATE TABLE Department( + id BIGINT PRIMARY KEY + ,number INTEGER NOT NULL UNIQUE + ,name CHAR(20) NOT NULL UNIQUE + ,parent CHAR(20) REFERENCES Department (name) + ON UPDATE CASCADE + ON DELETE SET NULL +); + diff --git a/ws/eclipse/Company/Sql/Final/schema.sql b/ws/eclipse/Company/Sql/Final/schema.sql new file mode 100644 index 0000000000000000000000000000000000000000..cafe92dafe85bbb384bd1b50d57ebd995751e4c5 --- /dev/null +++ b/ws/eclipse/Company/Sql/Final/schema.sql @@ -0,0 +1,34 @@ +drop table if exists Employee; +drop table if exists Project; +drop table if exists Department; +drop table if exists EmployeeProject; + +CREATE TABLE Department( + id BIGINT PRIMARY KEY + number INTEGER NOT NULL UNIQUE + ,name CHAR(20) NOT NULL UNIQUE + ,parent BIGINT REFERENCES Department +); + +CREATE TABLE Project ( + id BIGINT PRIMARY KEY + ,number INTEGER NOT NULL UNIQUE + ,name CHAR(20) NOT NULL UNIQUE +); + +CREATE TABLE Employee ( + id BIGINT PRIMARY KEY + ,number INTEGER NOT NULL UNIQUE + ,name CHAR(20) NOT NULL + ,surname CHAR(20) NOT NULL + ,department BIGINT NOT NULL REFERENCES Department + ,telephone CHAR(4) NOT NULL + ,fax CHAR(4) +); + +CREATE TABLE EmployeeProject ( + employee BIGINT NOT NULL REFERENCES Employee + ,project BIGINT NOT NULL REFERENCES Project + ,PRIMARY KEY(employee, project) + ,weeklyHours INTEGER NOT NULL +) \ No newline at end of file diff --git a/ws/eclipse/Company/pom.xml b/ws/eclipse/Company/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..61e62a7607654fbd22e5cb936e112dec7371bdd4 --- /dev/null +++ b/ws/eclipse/Company/pom.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>Company</groupId> + <artifactId>Company</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>de.hdm-stuttgart.mi.company</name> + <url>http://maven.apache.org</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.7</source> + <target>1.7</target> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>src/main/java</directory> + <includes> + <include> **/*.properties</include> + </includes> + </resource> + </resources> + + </build> + <dependencies> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>5.1.23</version> + </dependency> + </dependencies> +</project> diff --git a/ws/eclipse/Mediastore/Sql/200/schema.sql b/ws/eclipse/Mediastore/Sql/200/schema.sql new file mode 100644 index 0000000000000000000000000000000000000000..5bb0eab90832ce0b8ba23aba602d0adadca94216 --- /dev/null +++ b/ws/eclipse/Mediastore/Sql/200/schema.sql @@ -0,0 +1,45 @@ +drop table if exists ArtistAlbum; +drop table if exists Artist; +drop table if exists Track; +drop table if exists Album; +drop table if exists Format; + + +CREATE TABLE Format ( + id BIGINT PRIMARY KEY + ,name CHAR(20) NOT NULL UNIQUE + ,format SMALLINT NOT NULL +); + +CREATE TABLE Album ( + id BIGINT PRIMARY KEY + ,name CHAR(20) NOT NULL UNIQUE +); + +CREATE TABLE Track ( + name CHAR(20) NOT NULL UNIQUE + ,album BIGINT NOT NULL REFERENCES Album + ON DELETE CASCADE + ,UNIQUE (name, album) + ,format SMALLINT NOT NULL + ,CHECK (format in (1,2,3)) -- Mp3, Flac, Mp4 +); + +CREATE TABLE Artist ( + id BIGINT PRIMARY KEY + ,name CHAR(20) NOT NULL + ,surname CHAR(20) NOT NULL + ,sex SMALLINT NOT NULL + ,CHECK (sex in (1,2)) -- female, male -- +); + +CREATE TABLE ArtistAlbum ( + artist BIGINT NOT NULL REFERENCES Artist + ,album BIGINT NOT NULL REFERENCES Album + ,PRIMARY KEY(artist, album) + ,name CHAR(20) NOT NULL UNIQUE + ,isLead BOOLEAN NOT NULL +); + + +