add files for is-a excercise
This commit is contained in:
parent
7c49ea9476
commit
456129e2c8
18
db/3_sem/is_an_aircraft/is_an_aircraft.ssmssln
Normal file
18
db/3_sem/is_an_aircraft/is_an_aircraft.ssmssln
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# SQL Server Management Studio Solution File, Format Version 13.00
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{4F2E2C19-372F-40D8-9FA7-9D2138C6997A}") = "is_an_aircraft", "is_an_aircraft\is_an_aircraft.ssmssqlproj", "{F39278EA-3B78-45EE-90A4-FB370F21FF41}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Default|Default = Default|Default
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F39278EA-3B78-45EE-90A4-FB370F21FF41}.Default|Default.ActiveCfg = Default
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
10
db/3_sem/is_an_aircraft/is_an_aircraft/create_database.sql
Normal file
10
db/3_sem/is_an_aircraft/is_an_aircraft/create_database.sql
Normal file
|
@ -0,0 +1,10 @@
|
|||
-- Dateiname create_database.sql
|
||||
--
|
||||
-- Beschreibung: Is an Airplane Übung
|
||||
--
|
||||
-- Autor: Andreas Zweili
|
||||
-- Datum: 2017-05-27
|
||||
-- Server Version: SQL Server 2016
|
||||
|
||||
if not exists (select * from sys.databases where name='Luftfahrzeuge')
|
||||
CREATE DATABASE Luftfahrzeuge;
|
58
db/3_sem/is_an_aircraft/is_an_aircraft/create_table.sql
Normal file
58
db/3_sem/is_an_aircraft/is_an_aircraft/create_table.sql
Normal file
|
@ -0,0 +1,58 @@
|
|||
-- Dateiname create_table.sql
|
||||
--
|
||||
-- Beschreibung: Is an Airplane Übung
|
||||
--
|
||||
-- Autor: Andreas Zweili
|
||||
-- Datum: 2017-05-27
|
||||
-- Server Version: SQL Server 2016
|
||||
|
||||
use Luftfahrzeuge
|
||||
if not exists (select * from sysobjects where name='Luftfahrzeug')
|
||||
CREATE TABLE Luftfahrzeug (
|
||||
LFZ_ID int not null,
|
||||
LFZ_HERSTELLER varchar(40) not null,
|
||||
LFZ_BAUJAHR integer not null,
|
||||
constraint PK_LFZ_ID primary key (LFZ_ID)
|
||||
);
|
||||
|
||||
use Luftfahrzeuge
|
||||
if not exists (select * from sysobjects where name='Flugzeug')
|
||||
CREATE TABLE Flugzeug (
|
||||
FLZ_ID int not null,
|
||||
FLU_SPANNWEITE float,
|
||||
constraint PK_FLZ_ID primary key (FLZ_ID)
|
||||
);
|
||||
|
||||
use Luftfahrzeuge
|
||||
if not exists (select * from sysobjects where name='Hubschrauber')
|
||||
CREATE TABLE Hubschrauber (
|
||||
HUB_ID int not null,
|
||||
HUB_ROTORDURCHMESSER float,
|
||||
constraint PK_HUB_ID primary key (HUB_ID)
|
||||
);
|
||||
|
||||
use Luftfahrzeuge
|
||||
if not exists (select * from sysobjects where name='Zeppelin')
|
||||
CREATE TABLE Zeppelin (
|
||||
ZEP_ID int not null,
|
||||
ZEP_GASVOLUMEN float,
|
||||
constraint PK_ZEP_ID primary key (ZEP_ID)
|
||||
);
|
||||
|
||||
-- Foreign Key Constraints hinzufügen
|
||||
IF OBJECT_ID('dbo.[FK_LFZ_ID]', 'F') IS NULL
|
||||
ALTER TABLE Flugzeug ADD CONSTRAINT FK_LFZ_ID
|
||||
FOREIGN KEY (FLZ_ID) REFERENCES Luftfahrzeug (LFZ_ID);
|
||||
go
|
||||
|
||||
-- Foreign Key Constraints hinzufügen
|
||||
IF OBJECT_ID('dbo.[FK_LFZ_ID]', 'F') IS NULL
|
||||
ALTER TABLE Hubschrauber ADD CONSTRAINT FK_HUB_ID
|
||||
FOREIGN KEY (HUB_ID) REFERENCES Luftfahrzeug (LFZ_ID);
|
||||
go
|
||||
|
||||
-- Foreign Key Constraints hinzufügen
|
||||
IF OBJECT_ID('dbo.[FK_LFZ_ID]', 'F') IS NULL
|
||||
ALTER TABLE Zeppelin ADD CONSTRAINT FK_ZEP_ID
|
||||
FOREIGN KEY (ZEP_ID) REFERENCES Luftfahrzeug (LFZ_ID);
|
||||
go
|
21
db/3_sem/is_an_aircraft/is_an_aircraft/insert_data.sql
Normal file
21
db/3_sem/is_an_aircraft/is_an_aircraft/insert_data.sql
Normal file
|
@ -0,0 +1,21 @@
|
|||
-- Dateiname insert_data.sql
|
||||
--
|
||||
-- Beschreibung: Is an Airplane Übung
|
||||
--
|
||||
-- Autor: Andreas Zweili
|
||||
-- Datum: 2017-05-27
|
||||
-- Server Version: SQL Server 2016
|
||||
|
||||
|
||||
use Luftfahrzeuge
|
||||
|
||||
insert into dbo.Luftfahrzeug (LFZ_ID, LFZ_HERSTELLER, LFZ_BAUJAHR)
|
||||
values ('1000','Airbus','2012'),
|
||||
('2000','Alouette','1980');
|
||||
|
||||
insert into dbo.Flugzeug (FLZ_ID, FLU_SPANNWEITE)
|
||||
values ('1000','40');
|
||||
|
||||
|
||||
insert into dbo.Hubschrauber (HUB_ID, HUB_ROTORDURCHMESSER)
|
||||
values ('2000','8');
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0"?>
|
||||
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="is_an_aircraft">
|
||||
<Items>
|
||||
<LogicalFolder Name="Connections" Type="2" Sorted="true">
|
||||
<Items />
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Queries" Type="0" Sorted="true">
|
||||
<Items>
|
||||
<FileNode Name="create_table.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>create_table.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="insert_data.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>insert_data.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="remove_database.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>remove_database.sql</FullPath>
|
||||
</FileNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Miscellaneous" Type="3" Sorted="true">
|
||||
<Items />
|
||||
</LogicalFolder>
|
||||
</Items>
|
||||
</SqlWorkbenchSqlProject>
|
23
db/3_sem/is_an_aircraft/is_an_aircraft/remove_database.sql
Normal file
23
db/3_sem/is_an_aircraft/is_an_aircraft/remove_database.sql
Normal file
|
@ -0,0 +1,23 @@
|
|||
-- Removes the tables for the Flugzeug DB
|
||||
--
|
||||
-- Author: Andreas Zweili
|
||||
-- Erstellt: 2017-05-27
|
||||
-- DB-Server SQL Server 2016
|
||||
|
||||
use Luftfahrzeuge;
|
||||
|
||||
if exists (select * from sysobjects where name='Flugzeug')
|
||||
drop table Flugzeug;
|
||||
|
||||
if exists (select * from sysobjects where name='Hubschrauber')
|
||||
drop table Hubschrauber;
|
||||
|
||||
if exists (select * from sysobjects where name='Zeppelin')
|
||||
drop table Zeppelin;
|
||||
|
||||
if exists (select * from sysobjects where name='Luftfahrzeug')
|
||||
drop table Luftfahrzeug;
|
||||
|
||||
use master;
|
||||
if exists (select * from sys.databases where name='Luftfahrzeuge')
|
||||
drop DATABASE Luftfahrzeuge;
|
Reference in New Issue
Block a user