Merge branch 'master' of git.2li.ch:Nebucatnetzer/ibz
This commit is contained in:
commit
773ed5e20e
|
@ -605,4 +605,5 @@ target/
|
|||
*.out
|
||||
*.pdf
|
||||
*.toc
|
||||
*.gz
|
||||
*.gz
|
||||
.idea
|
||||
|
|
|
@ -1,64 +1,52 @@
|
|||
<?xml version="1.0"?>
|
||||
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="Abo">
|
||||
<Items>
|
||||
<LogicalFolder Name="Connections" Type="2" Sorted="true">
|
||||
<Items>
|
||||
<ConnectionNode Name="WIN-10-SFR\SQL2016:WIN-LAPTOP\andreas">
|
||||
<Created>2017-03-09T18:45:47.4395012+01:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>WIN-10-SFR\SQL2016</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>15</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="WIN-LAPTOP\SQLEXPRESS:WIN-LAPTOP\andreas">
|
||||
<Created>2017-03-11T08:58:56.8900889+01:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>WIN-LAPTOP\SQLEXPRESS</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>15</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
|
||||
</ConnectionNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Queries" Type="0" Sorted="true">
|
||||
<Items>
|
||||
<FileNode Name="create_tables.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:WIN-10-SFR\SQL2016:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>WIN-10-SFR\SQL2016</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>create_tables.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="insert_data.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:WIN-10-SFR\SQL2016:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>WIN-10-SFR\SQL2016</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>insert_data.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="remove_tables.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:WIN-10-SFR\SQL2016:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>WIN-10-SFR\SQL2016</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>remove_tables.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="select_statements.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:WIN-LAPTOP\SQLEXPRESS:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>WIN-LAPTOP\SQLEXPRESS</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>select_statements.sql</FullPath>
|
||||
</FileNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Miscellaneous" Type="3" Sorted="true">
|
||||
<Items />
|
||||
</LogicalFolder>
|
||||
</Items>
|
||||
<?xml version="1.0"?>
|
||||
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="Abo">
|
||||
<Items>
|
||||
<LogicalFolder Name="Connections" Type="2" Sorted="true">
|
||||
<Items>
|
||||
<ConnectionNode Name="(local)\SQLEXPRESS:WIN-LAPTOP\andreas">
|
||||
<Created>2017-06-03T11:37:38.3249035+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>(local)\SQLEXPRESS</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>15</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Queries" Type="0" Sorted="true">
|
||||
<Items>
|
||||
<FileNode Name="create_tables.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>create_tables.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="insert_data.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>insert_data.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="remove_tables.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>remove_tables.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="select_statements.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>select_statements.sql</FullPath>
|
||||
</FileNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Miscellaneous" Type="3" Sorted="true">
|
||||
<Items />
|
||||
</LogicalFolder>
|
||||
</Items>
|
||||
</SqlWorkbenchSqlProject>
|
|
@ -0,0 +1,21 @@
|
|||
use Abo;
|
||||
go
|
||||
|
||||
-- create a view
|
||||
create view mitglieder_liste
(Anr, Vor, Nach)
|
||||
as
|
||||
select anrede.anrede,
|
||||
mitglied.mitglied_vorname,
|
||||
mitglied.mitglied_name
|
||||
from mitglied inner join anrede
|
||||
on mitglied.anrede_id = anrede.anrede_id;
|
||||
|
||||
-- query the view
|
||||
|
||||
use Abo;
|
||||
go
|
||||
|
||||
select * from mitglieder_liste;
|
||||
go
|
||||
|
||||
drop view mitglieder_liste;
|
|
@ -1,13 +1,3 @@
|
|||
<<<<<<< HEAD
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="SqlWorkbenchSqlProject">
|
||||
<Items>
|
||||
<LogicalFolder Name="Connections" Type="2" />
|
||||
<LogicalFolder Name="Queries" Type="0" />
|
||||
<LogicalFolder Name="Miscellaneous" Type="3" />
|
||||
|
||||
</Items>
|
||||
=======
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="SqlWorkbenchSqlProject">
|
||||
<Items>
|
||||
|
@ -16,5 +6,4 @@
|
|||
<LogicalFolder Name="Miscellaneous" Type="3" />
|
||||
|
||||
</Items>
|
||||
>>>>>>> 91c37e0a13ad9148d1d6356ee6197441ad0a42e5
|
||||
</SqlWorkbenchSqlProject>
|
|
@ -1,4 +1,3 @@
|
|||
<<<<<<< HEAD
|
||||
-- Dateiname zweili_andreas_A1.sql
|
||||
--
|
||||
-- Beschreibung: SEP Datenbank 2 Gartencenter
|
||||
|
@ -8,6 +7,9 @@
|
|||
-- Server Version: SQL Server 2016
|
||||
|
||||
-- Tabelle Lieferant erstellen
|
||||
if not exists (select * from sys.databases where name='Gartencenter')
|
||||
CREATE DATABASE Gartencenter;
|
||||
|
||||
use Gartencenter
|
||||
if not exists (select * from sysobjects where name='Lieferant')
|
||||
CREATE TABLE Lieferant (
|
||||
|
@ -113,121 +115,4 @@ go
|
|||
IF OBJECT_ID('dbo.[C_BES_LIEFERDATUM]', 'C') IS NULL
|
||||
ALTER TABLE Bestellung ADD CONSTRAINT C_BES_LIEFERDATUM
|
||||
CHECK (Bestellung.BES_LIEFERDATUM > CURRENT_TIMESTAMP)
|
||||
go
|
||||
=======
|
||||
-- Dateiname zweili_andreas_A1.sql
|
||||
--
|
||||
-- Beschreibung: SEP Datenbank 2 Gartencenter
|
||||
--
|
||||
-- Autor: Andreas Zweili
|
||||
-- Datum: 11.03.2017
|
||||
-- Server Version: SQL Server 2016
|
||||
|
||||
-- Tabelle Lieferant erstellen
|
||||
use Gartencenter
|
||||
if not exists (select * from sysobjects where name='Lieferant')
|
||||
CREATE TABLE Lieferant (
|
||||
LFR_CODE int identity(1,1) not null,
|
||||
LFR_NAME varchar(40) null,
|
||||
LFR_ADRESSE varchar(40) null,
|
||||
LFR_PLZ int null,
|
||||
LFR_WOHNORT varchar(40) null
|
||||
constraint PK_LFR_CODE primary key (LFR_CODE)
|
||||
);
|
||||
go
|
||||
|
||||
-- Tabelle Bestellung erstellen
|
||||
use Gartencenter
|
||||
if not exists (select * from sysobjects where name='Bestellung')
|
||||
CREATE TABLE Bestellung (
|
||||
BES_ID int identity(1,1) not null,
|
||||
BES_BESTELLDATUM date not null,
|
||||
BES_LIEFERDATUM date not null,
|
||||
BES_BETRAG float not null,
|
||||
LFR_CODE int not null
|
||||
constraint PK_BES_ID primary key (BES_ID)
|
||||
);
|
||||
go
|
||||
|
||||
-- Tabelle Pflanze erstellen
|
||||
use Gartencenter
|
||||
if not exists (select * from sysobjects where name='Pflanze')
|
||||
CREATE TABLE Pflanze (
|
||||
PFL_ID int identity(1,1) not null,
|
||||
PFL_NAME varchar(40) null,
|
||||
PFL_SORTE varchar(40) null,
|
||||
PFL_FARBE varchar(40) null,
|
||||
PFL_HOEHE float null,
|
||||
PFL_BEGIN date null,
|
||||
PFL_END date null,
|
||||
PFL_PREIS float null
|
||||
constraint PK_PFL_ID primary key (PFL_ID)
|
||||
);
|
||||
go
|
||||
|
||||
-- Tabelle Angebot erstellen
|
||||
use Gartencenter
|
||||
if not exists (select * from sysobjects where name='Angebot')
|
||||
CREATE TABLE Angebot (
|
||||
ANG_ID int identity(1,1) not null,
|
||||
PFL_ID int not null,
|
||||
LFR_CODE int not null,
|
||||
ANG_PREIS varchar(40) null,
|
||||
ANG_LIEFERZEIT int null
|
||||
constraint PK_ANG_ID primary key (ANG_ID)
|
||||
);
|
||||
go
|
||||
|
||||
-- Tabelle Bestelldaten erstellen
|
||||
use Gartencenter
|
||||
if not exists (select * from sysobjects where name='Bestelldaten')
|
||||
CREATE TABLE Bestelldaten (
|
||||
ANG_ID int not null,
|
||||
BES_ID int not null,
|
||||
BED_ANZAHL int null,
|
||||
BED_EINZELPREIS float null
|
||||
constraint PK_BESTELLDATEN primary key (ANG_ID, BES_ID)
|
||||
);
|
||||
go
|
||||
|
||||
|
||||
-- Foreign Key Constraints hinzufügen
|
||||
IF OBJECT_ID('dbo.[FK_LFR_CODE]', 'F') IS NULL
|
||||
ALTER TABLE Bestellung ADD CONSTRAINT FK_LFR_CODE
|
||||
FOREIGN KEY (LFR_CODE) REFERENCES Lieferant (LFR_CODE);
|
||||
go
|
||||
|
||||
IF OBJECT_ID('dbo.[FK_PFL_ID]', 'F') IS NULL
|
||||
ALTER TABLE Angebot ADD CONSTRAINT FK_PFL_ID
|
||||
FOREIGN KEY (PFL_ID) REFERENCES Pflanze (PFL_ID);
|
||||
go
|
||||
|
||||
IF OBJECT_ID('dbo.[FK_LFR_CODE_ANGEBOT]', 'F') IS NULL
|
||||
ALTER TABLE Angebot ADD CONSTRAINT FK_LFR_CODE_ANGEBOT
|
||||
FOREIGN KEY (LFR_CODE) REFERENCES Lieferant (LFR_CODE);
|
||||
go
|
||||
|
||||
IF OBJECT_ID('dbo.[FK_BESTELLUNG_ANGEBOT]', 'F') IS NULL
|
||||
ALTER TABLE Bestelldaten ADD CONSTRAINT FK_BESTELLUNG_ANGEBOT
|
||||
FOREIGN KEY (ANG_ID) REFERENCES Angebot(ANG_ID),
|
||||
FOREIGN KEY (BES_ID) REFERENCES Bestellung(BES_ID);
|
||||
go
|
||||
|
||||
-- Check Constraints on Pflanze
|
||||
IF OBJECT_ID('dbo.[C_PFL_PREIS]', 'C') IS NULL
|
||||
ALTER TABLE Pflanze ADD CONSTRAINT C_PFL_PREIS
|
||||
CHECK (Pflanze.PFL_PREIS > 0.0);
|
||||
go
|
||||
|
||||
IF OBJECT_ID('dbo.[C_PFL_END]', 'C') IS NULL
|
||||
ALTER TABLE Pflanze ADD CONSTRAINT C_PFL_END
|
||||
CHECK (Pflanze.PFL_BEGIN < Pflanze.PFL_END);
|
||||
go
|
||||
|
||||
-- Check Constraint on Bestellung
|
||||
|
||||
IF OBJECT_ID('dbo.[C_BES_LIEFERDATUM]', 'C') IS NULL
|
||||
ALTER TABLE Bestellung ADD CONSTRAINT C_BES_LIEFERDATUM
|
||||
CHECK (Bestellung.BES_LIEFERDATUM > CURRENT_TIMESTAMP)
|
||||
go
|
||||
>>>>>>> 91c37e0a13ad9148d1d6356ee6197441ad0a42e5
|
||||
|
|
|
@ -1,74 +1,3 @@
|
|||
<<<<<<< HEAD
|
||||
-- Dateiname zweili_andreas_A2.sql
|
||||
--
|
||||
-- Beschreibung: SEP Datenbank 2
|
||||
--
|
||||
-- Autor: Andreas Zweili
|
||||
-- Datum: 11.03.2017
|
||||
|
||||
|
||||
-- A2.1
|
||||
use Abo
|
||||
select m.mitglied_name, m.mitglied_vorname, m.eintrittsdatum from mitglied m
|
||||
inner join anrede a
|
||||
on a.anrede_id = m.anrede_id
|
||||
order by m.mitglied_name ASC, m.mitglied_vorname ASC;
|
||||
|
||||
|
||||
|
||||
-- A2.2
|
||||
use Abo
|
||||
select m.mitglied_name, m.mitglied_vorname, m.eintrittsdatum, abo.abo_gebuehr from mitglied m
|
||||
inner join abo
|
||||
on abo.abo_id = m.abo_id
|
||||
where abo.abo_gebuehr > '1000';
|
||||
|
||||
-- A2.3
|
||||
use Abo
|
||||
select * from mitglied m
|
||||
where m.mitglied_name like '%ll%'
|
||||
order by m.mitglied_id DESC;
|
||||
|
||||
-- A2.4
|
||||
use Abo
|
||||
select * from mitglied m
|
||||
where m.eintrittsdatum is NULL;
|
||||
|
||||
-- A2.5
|
||||
use Abo
|
||||
select m.mitglied_name, m.mitglied_vorname, m.eintrittsdatum, o.postleizahl, o.ortsname
|
||||
from mitglied m
|
||||
inner join ort o on m.ort_id = o.ort_id
|
||||
where m.eintrittsdatum between convert(date, '01.01.1990', 104) and convert(date, '31.12.1995', 104)
|
||||
order by o.postleizahl asc;
|
||||
|
||||
-- A2.6
|
||||
use Abo
|
||||
select a.anrede, m.mitglied_name, m.mitglied_vorname, o.postleizahl, o.ortsname, abo_name from mitglied m
|
||||
inner join anrede a
|
||||
on a.anrede_id = m.anrede_id
|
||||
inner join ort o
|
||||
on o.ort_id = m.ort_id
|
||||
inner join abo
|
||||
on m.abo_id = abo.abo_id
|
||||
where a.anrede = 'Herr'
|
||||
and (o.ortsname = 'Basel'
|
||||
or o.ortsname = 'Zürich');
|
||||
|
||||
-- A2.7
|
||||
|
||||
update abo set
|
||||
abo.abo_gebuehr = '550'
|
||||
where abo.abo_name = 'Student';
|
||||
update abo set
|
||||
abo.abo_gebuehr = '165'
|
||||
where abo.abo_name = 'Monatsabo';
|
||||
|
||||
-- A2.8
|
||||
|
||||
delete from mitglied
|
||||
where mitglied_name = 'Keller'
|
||||
=======
|
||||
-- Dateiname zweili_andreas_A2.sql
|
||||
--
|
||||
-- Beschreibung: SEP Datenbank 2
|
||||
|
@ -138,5 +67,4 @@ update abo set
|
|||
|
||||
delete from mitglied
|
||||
where mitglied_name = 'Keller'
|
||||
>>>>>>> 91c37e0a13ad9148d1d6356ee6197441ad0a42e5
|
||||
and mitglied_vorname = 'Georg';
|
|
@ -0,0 +1,24 @@
|
|||
-- Queuries to create test table and change the permissions of the underpriviledged user
|
||||
|
||||
use IBZ;
|
||||
|
||||
create table SprechendeTiere
|
||||
(
|
||||
ID int identity(1,1) not null,
|
||||
Tierame varchar(50)
|
||||
constraint pk_sprechende_tiere primary key (ID)
|
||||
);
|
||||
|
||||
|
||||
insert into SprechendeTiere(Tierame)
|
||||
values ('Einhorn');
|
||||
|
||||
-- Grant
|
||||
|
||||
grant select on SprechendeTiere to ibzadmin;
|
||||
|
||||
grant delete on SprechendeTiere to ibzadmin;
|
||||
|
||||
grant update on SprechendeTiere to ibzadmin;
|
||||
|
||||
grant all on SprechendeTiere to ibzadmin;
|
|
@ -0,0 +1,16 @@
|
|||
-- Test Queries for an unprivileged user
|
||||
|
||||
use IBZ;
|
||||
|
||||
select * from SprechendeTiere;
|
||||
|
||||
delete SprechendeTiere
|
||||
where Tierame='Einhorn';
|
||||
|
||||
update SprechendeTiere
|
||||
set Tierame='Einhörner'
|
||||
where Tierame='Einhorn';
|
||||
|
||||
|
||||
insert into SprechendeTiere(Tierame)
|
||||
values ('Papagei');
|
|
@ -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
|
|
@ -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;
|
|
@ -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_FLZ_ID]', 'F') IS NULL
|
||||
ALTER TABLE Flugzeug ADD CONSTRAINT FK_FLZ_ID
|
||||
FOREIGN KEY (FLZ_ID) REFERENCES Luftfahrzeug (LFZ_ID);
|
||||
go
|
||||
|
||||
-- Foreign Key Constraints hinzufügen
|
||||
IF OBJECT_ID('dbo.[FK_HUB_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_ZEP_ID]', 'F') IS NULL
|
||||
ALTER TABLE Zeppelin ADD CONSTRAINT FK_ZEP_ID
|
||||
FOREIGN KEY (ZEP_ID) REFERENCES Luftfahrzeug (LFZ_ID);
|
||||
go
|
|
@ -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,58 @@
|
|||
<?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>
|
||||
<ConnectionNode Name="WIN-10-SFR\SQL2016:WIN-10-SFR\andreas">
|
||||
<Created>2017-05-27T17:43:46.0617539+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>WIN-10-SFR\SQL2016</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>15</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
|
||||
</ConnectionNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Queries" Type="0" Sorted="true">
|
||||
<Items>
|
||||
<FileNode Name="create_database.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:WIN-10-SFR\SQL2016:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>WIN-10-SFR\SQL2016</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>create_database.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="create_table.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:WIN-10-SFR\SQL2016:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>WIN-10-SFR\SQL2016</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>create_table.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="insert_data.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:WIN-10-SFR\SQL2016:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>WIN-10-SFR\SQL2016</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>insert_data.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="remove_database.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:WIN-10-SFR\SQL2016:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>WIN-10-SFR\SQL2016</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>remove_database.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="selections.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:WIN-10-SFR\SQL2016:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>WIN-10-SFR\SQL2016</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>selections.sql</FullPath>
|
||||
</FileNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Miscellaneous" Type="3" Sorted="true">
|
||||
<Items />
|
||||
</LogicalFolder>
|
||||
</Items>
|
||||
</SqlWorkbenchSqlProject>
|
|
@ -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;
|
|
@ -0,0 +1,23 @@
|
|||
-- Dateiname selections.sql
|
||||
--
|
||||
-- Beschreibung: Is an Airplane Übung
|
||||
--
|
||||
-- Autor: Andreas Zweili
|
||||
-- Datum: 2017-05-27
|
||||
-- Server Version: SQL Server 2016
|
||||
|
||||
use Luftfahrzeuge
|
||||
select l.LFZ_ID, l.LFZ_HERSTELLER, l.LFZ_BAUJAHR,
|
||||
f.FLU_SPANNWEITE from Luftfahrzeug l
|
||||
inner join Flugzeug f
|
||||
on f.FLZ_ID = l.LFZ_ID;
|
||||
|
||||
select l.LFZ_ID, l.LFZ_HERSTELLER, l.LFZ_BAUJAHR,
|
||||
h.HUB_ROTORDURCHMESSER from Luftfahrzeug l
|
||||
inner join Hubschrauber h
|
||||
on h.HUB_ID = l.LFZ_ID;
|
||||
|
||||
select l.LFZ_ID, l.LFZ_HERSTELLER, l.LFZ_BAUJAHR,
|
||||
z.ZEP_GASVOLUMEN from Luftfahrzeug l
|
||||
inner join Zeppelin z
|
||||
on z.ZEP_ID = l.LFZ_ID;
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
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}") = "recursion_excercise", "recursion_excercise\recursion_excercise.ssmssqlproj", "{DBD36523-4CE3-4DFD-B808-1390BF12E72C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Default|Default = Default|Default
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DBD36523-4CE3-4DFD-B808-1390BF12E72C}.Default|Default.ActiveCfg = Default
|
||||
{A6A62C4A-1940-4632-91E2-D99051C5F539}.Default|Default.ActiveCfg = Default
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,627 @@
|
|||
use bike_shop
|
||||
delete from struktur
|
||||
delete from teile
|
||||
go
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(1,'Stück','Rocky Mountain Element Race', 'Artikel',
|
||||
2600,0, 20, 10, 20, 20, 2, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(2,'Stück','Rahmen Element Race', 'Baugruppe',
|
||||
300,0, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(3,'kg','Silberfarbe', 'Material',
|
||||
0,2, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(4,'kg','Sintermetall', 'Material',
|
||||
0,5, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(5,'Stück','Gabel SID XC', 'Material',
|
||||
0,1230, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(24,'Stück','Tretlager Race Face', 'Material',
|
||||
0,18, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(7,'Stück','Kurbelsatz Race Face', 'Material',
|
||||
0,18, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(8,'Stück','Schaltwerk XTR', 'Material',
|
||||
0,150, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(9,'Stück','Pedale Shimano 747', 'Material',
|
||||
0,5, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(10,'Stück','Schalthebel Grip Shift', 'Material',
|
||||
0,79, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(11,'Stück','Rad xtr', 'Baugruppe',
|
||||
50,0, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(12,'Stück','Naben Mavic Crossmax', 'Material',
|
||||
0, 0.50 , 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(13,'Stück','Felgen Mavic Crossmax', 'Material',
|
||||
0, 0.60 , 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(14,'Stück','Speichen Mavic Crossmax', 'Material',
|
||||
0, 0.50 , 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(15,'Stück','Bereifung Richtey, Vo: Z-Max ', 'Material',
|
||||
0, 22, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(16,'Stück','Steuersatz Chris King', 'Material',
|
||||
0, 28, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(17,'Stück','Vorbau Control Tech', 'Material',
|
||||
0, 28, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(18,'Stück','Lenker Answer Hyperlite', 'Material',
|
||||
0, 109, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(19,'Stück','Griffe LGrip Shift ', 'Material',
|
||||
0, 10, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(20,'Stück','Bremshebel XTR', 'Material',
|
||||
0, 11, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(21,'Stück','Bremsen XTR', 'Material',
|
||||
0, 110, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(22,'Stück','Sattel Flite', 'Material',
|
||||
0, 60, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(28,'Stück','Bremse Shimano Alivio Cantilever ', 'Material',
|
||||
0, 29, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(23,'Stück','Sattelstütze Syncros', 'Material',
|
||||
0, 28, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(25,'Stück','Bremse Shimano XTR V-Brake ', 'Material',
|
||||
0, 149, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(26,'Stück','GABEL TOP GUN ', 'Material',
|
||||
0, 299, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(27,'Stück','Shimano STX-RC i', 'Material',
|
||||
0,69, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(29,'Stück','Rahmen Cannondale CAD3 Headshok', 'Material',
|
||||
0,1590, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(30,'Stück','Rahmen Super V', 'Material',
|
||||
0,2590, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(31,'Stück','Herrenrad GT-LTS 18', 'Artikel',
|
||||
3000,0, 20, 10, 20, 20, 2, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(32,'Stück','Rahmen GT-LTS 18"', 'Baugruppe',
|
||||
300,0, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(33,'kg','Vb-Farbe', 'Material',
|
||||
0,2, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(34,'kg','Aluminium', 'Material',
|
||||
0,8, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(35,'Stück','RST Hi-5', 'Material',
|
||||
0,30, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(36,'Stück','Race Face (TITAN)', 'Material',
|
||||
0,18, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(37,'Stück','Kurbelsatz Ritchey Logic', 'Material',
|
||||
0,19, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(38,'Stück','Schaltwerk XTR inverse', 'Material',
|
||||
0,252, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(39,'Stück','Pedale XT', 'Material',
|
||||
0,9, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(40,'Stück','Schalthebel Grip Shift 4', 'Material',
|
||||
0,9, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(41,'Stück','Rad XTR 47', 'Baugruppe',
|
||||
60,0, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(42,'Stück','Naben Inferno', 'Material',
|
||||
0, 0.50 , 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(43,'Stück','Felgen Inferno', 'Material',
|
||||
0, 0.60 , 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(44,'Stück','Speichen Mavic Crossmax', 'Material',
|
||||
0, 0.50 , 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(45,'Stück','Bereifung Continental ', 'Material',
|
||||
0, 22, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(46,'Stück','Steuersatz Race Face', 'Material',
|
||||
0, 28, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(47,'Stück','Vorbau Syncros', 'Material',
|
||||
0, 70, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(48,'Stück','Lenker Syncros (Downhill)', 'Material',
|
||||
0, 140, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(49,'Stück','Griffe LGrip Shift ', 'Material',
|
||||
0, 10, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(50,'Stück','Bremshebel TWP G-Force', 'Material',
|
||||
0, 17, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(51,'Stück','Bremsen Magura Race Line', 'Material',
|
||||
0, 150, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(52,'Stück','Sattel Selle Flite Titanium', 'Material',
|
||||
0, 80, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(53,'Stück','Sattelstütze XTR', 'Material',
|
||||
0, 30, 20, 10, 10, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(54,'Stück','Klapprad Prompton P3', 'Artikel',
|
||||
0, 1200, 20, 10, 10, 10, 0, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(55,'Stück','CANNONDALE FSL', 'Artikel',
|
||||
0, 4200, 20, 10, 10, 10, 0, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(56,'Stück','HERCULES NEPAL', 'Artikel',
|
||||
0, 1200, 20, 10, 10, 10, 0, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(57,'Stück','Steppenwolf TAO', 'Artikel',
|
||||
0, 1600, 20, 10, 10, 10, 0, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(58,'Stück','SWITCHBACK AGENT', 'Artikel',
|
||||
0, 599, 20, 10, 10, 10, 0, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(59,'Stück','STEVENS R.P.R.2 RX100 8FACH', 'Artikel',
|
||||
0, 1700, 20, 10, 10, 10, 0, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(60,'Stück','Scott ATACAMA TOUR', 'Artikel',
|
||||
0, 1899, 20, 10, 10, 10, 0, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(61,'Stück','ROTWILD RCC-03', 'Artikel',
|
||||
0, 3280, 20, 10, 10, 10, 0, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO teile
|
||||
VALUES
|
||||
(62,'Stück','Lenker', 'Baugruppe',
|
||||
0, 280, 20, 10, 10, 10, 0, 0, 0, getdate())
|
||||
|
||||
go
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 2, 1, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(2, 3, 2, 10, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(2, 4, 3, 20, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 5, 4, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 24, 5, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 7, 6, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 8, 7, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 9, 8, 2, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 10, 9, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 11, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 16, 11, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 17, 12, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 18, 13, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 19, 14, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 20, 15, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 21, 16, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 22, 17, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(1, 23, 18, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(11, 12, 1, 50, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(11, 13, 2, 50, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(11, 14, 3, 50, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(11, 15, 4, 2, 0, 0, getdate())
|
||||
|
||||
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 32, 1, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(32, 33, 2, 10, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(32, 34, 3, 20, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 35, 4, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 44, 5, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 37, 6, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 38, 7, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 39, 8, 2, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 40, 9, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 41, 10, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 46, 11, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 47, 12, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 48, 13, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 49, 14, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 50, 15, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 51, 16, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 52, 17, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(31, 53, 18, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(41, 42, 1, 50, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(41, 43, 2, 50, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(41, 44, 3, 50, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(41, 45, 4, 2, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(60, 2, 1, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(60, 41, 1, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(60, 62, 1, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(62, 49, 1, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(62, 40, 1, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(40, 34, 1, 1, 0, 0, getdate())
|
||||
|
||||
|
||||
INSERT INTO struktur
|
||||
VALUES
|
||||
(40, 3, 1, 1, 0, 0, getdate())
|
|
@ -0,0 +1,10 @@
|
|||
-- Dateiname create_database.sql
|
||||
--
|
||||
-- Beschreibung: recursion excercise
|
||||
--
|
||||
-- Autor: Andreas Zweili
|
||||
-- Datum: 2017-05-28
|
||||
-- Server Version: SQL Server 2016
|
||||
|
||||
if not exists (select * from sys.databases where name='bike_shop')
|
||||
CREATE DATABASE bike_shop;
|
|
@ -0,0 +1,52 @@
|
|||
-- Dateiname create_table.sql
|
||||
--
|
||||
-- Beschreibung: recursion excercise
|
||||
--
|
||||
-- Autor: Andreas Zweili
|
||||
-- Datum: 2017-05-28
|
||||
-- Server Version: SQL Server 2016
|
||||
|
||||
use bike_shop
|
||||
if not exists (select * from sysobjects where name='teile')
|
||||
CREATE TABLE teile(
|
||||
TNr int not null,
|
||||
Me varchar(10),
|
||||
Bezeichnung varchar(50),
|
||||
Typ varchar(50),
|
||||
Herstellkosten float,
|
||||
Einkaufspreis float,
|
||||
Mindestbestand int,
|
||||
Bestand int,
|
||||
Lieferzeit int,
|
||||
Herstelldauer int,
|
||||
Gewicht int,
|
||||
Reserviert int,
|
||||
Verfügbar int,
|
||||
Zeitstempel DATE,
|
||||
constraint PK_TNr primary key (TNr)
|
||||
);
|
||||
|
||||
use bike_shop
|
||||
if not exists (select * from sysobjects where name='struktur')
|
||||
CREATE TABLE struktur(
|
||||
OTeil int,
|
||||
UTeil int,
|
||||
Position int not null,
|
||||
Menge int,
|
||||
Ausschuss int,
|
||||
Arbeitsgang int,
|
||||
Zeitstempel DATE,
|
||||
constraint PK_POS primary key (OTeil, UTeil, Position)
|
||||
);
|
||||
|
||||
-- Foreign Key Constraints hinzufügen
|
||||
IF OBJECT_ID('dbo.[FK_OTeil]', 'O') IS NULL
|
||||
ALTER TABLE struktur ADD CONSTRAINT FK_OTeil
|
||||
FOREIGN KEY (OTeil) REFERENCES teile (TNr);
|
||||
go
|
||||
|
||||
-- Foreign Key Constraints hinzufügen
|
||||
IF OBJECT_ID('dbo.[FK_UTeil]', 'U') IS NULL
|
||||
ALTER TABLE struktur ADD CONSTRAINT FK_UTeil
|
||||
FOREIGN KEY (UTeil) REFERENCES teile (TNr);
|
||||
go
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0"?>
|
||||
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="recursion_excercise">
|
||||
<Items>
|
||||
<LogicalFolder Name="Connections" Type="2" Sorted="true">
|
||||
<Items>
|
||||
<ConnectionNode Name="(local)\SQLEXPRESS:WIN-LAPTOP\andreas">
|
||||
<Created>2017-06-03T08:55:35.46851+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>(local)\SQLEXPRESS</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>15</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Queries" Type="0" Sorted="true">
|
||||
<Items>
|
||||
<FileNode Name="create_database.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>create_database.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="create_table.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>create_table.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="remove_database.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>remove_database.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="selections.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>selections.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="TeileInsert.sql">
|
||||
<AssociatedConnectionMoniker />
|
||||
<AssociatedConnSrvName />
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>TeileInsert.sql</FullPath>
|
||||
</FileNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Miscellaneous" Type="3" Sorted="true">
|
||||
<Items />
|
||||
</LogicalFolder>
|
||||
</Items>
|
||||
</SqlWorkbenchSqlProject>
|
|
@ -0,0 +1,17 @@
|
|||
-- Removes the bike_shop DB
|
||||
--
|
||||
-- Author: Andreas Zweili
|
||||
-- Erstellt: 2017-05-28
|
||||
-- DB-Server SQL Server 2016
|
||||
|
||||
use bike_shop;
|
||||
|
||||
if exists (select * from sysobjects where name='teile')
|
||||
drop table teile;
|
||||
|
||||
if exists (select * from sysobjects where name='struktur')
|
||||
drop table struktur;
|
||||
|
||||
use master;
|
||||
if exists (select * from sys.databases where name='bike_shop')
|
||||
drop DATABASE bike_shop;
|
|
@ -0,0 +1,29 @@
|
|||
-- Dateiname selections.sql
|
||||
--
|
||||
-- Beschreibung: recursion excercise
|
||||
--
|
||||
-- Autor: Andreas Zweili
|
||||
-- Datum: 2017-05-28
|
||||
-- Server Version: SQL Server 2016
|
||||
|
||||
use bike_shop
|
||||
select t.TNr, t.Bezeichnung, t.Typ,
|
||||
s.Position, s.OTeil, s.Menge from teile t
|
||||
inner join struktur s
|
||||
on t.TNr = s.OTeil;
|
||||
|
||||
select * from struktur
|
||||
where struktur.OTeil=60;
|
||||
|
||||
select * from dbo.teile
|
||||
where teile.TNr in (2,41,62);
|
||||
|
||||
select t1.TNr,
|
||||
t1.Bezeichnung,
|
||||
s1.UTeil,
|
||||
t2.Bezeichnung
|
||||
from teile t1 inner join struktur s1
|
||||
on t1.TNr = s1.OTeil
|
||||
inner join teile t2
|
||||
on t2.TNr = s1.UTeil
|
||||
where t1.TNr=60
|
Reference in New Issue