Witam wszystkich. Na zaliczenie baz danych mamy zrobić projekt w powerdesigner jednak mam z tym duży problem. Nie ukrywam że jestem z tego totalnie zielony i widać coś zrobiłem źle bo po wygenerowaniu skryptu sql i wklejeniu go do SQL Anywhere otrzymuje błędy. Nie wiem czy moja baza jest źle zaprojektowana czy też coś źle robię w tym drugim programie tak więc zamieszczam całość na forum i proszę o porady.
A tu zamieszczam zawartość pliku SQL:
/*==============================================================*/
/* DBMS name: Sybase SQL Anywhere 10 */
/* Created on: 2010-01-24 17:00:10 */
/*==============================================================*/
if exists(select 1 from sys.sysforeignkey where role='FK_KIEROWCA_ZAWODNICY_KLUBY') then
alter table Kierowca
delete foreign key FK_KIEROWCA_ZAWODNICY_KLUBY
end if;
if exists(select 1 from sys.sysforeignkey where role='FK_SAMOCHOD_AUTA_KLUBY') then
alter table Samochod
delete foreign key FK_SAMOCHOD_AUTA_KLUBY
end if;
if exists(select 1 from sys.sysforeignkey where role='FK_SAMOCHOD_POBYT_WARSZTAT') then
alter table Samochod
delete foreign key FK_SAMOCHOD_POBYT_WARSZTAT
end if;
if exists(select 1 from sys.sysforeignkey where role='FK_WARSZTAT_NAPRAWA_KLUBY') then
alter table WARSZTAT
delete foreign key FK_WARSZTAT_NAPRAWA_KLUBY
end if;
if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Zawodnicy_FK'
and t.table_name='Kierowca'
) then
drop index Kierowca.Zawodnicy_FK
end if;
if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Kierowca_PK'
and t.table_name='Kierowca'
) then
drop index Kierowca.Kierowca_PK
end if;
if exists(
select 1 from sys.systable
where table_name='Kierowca'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table Kierowca
end if;
if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Kluby_PK'
and t.table_name='Kluby'
) then
drop index Kluby.Kluby_PK
end if;
if exists(
select 1 from sys.systable
where table_name='Kluby'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table Kluby
end if;
if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Miejsce_FK'
and t.table_name='Samochod'
) then
drop index Samochod.Miejsce_FK
end if;
if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Auta_FK'
and t.table_name='Samochod'
) then
drop index Samochod.Auta_FK
end if;
if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Samochod_PK'
and t.table_name='Samochod'
) then
drop index Samochod.Samochod_PK
end if;
if exists(
select 1 from sys.systable
where table_name='Samochod'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table Samochod
end if;
if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Naprawa_FK'
and t.table_name='WARSZTAT'
) then
drop index WARSZTAT.Naprawa_FK
end if;
if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='WARSZTAT_PK'
and t.table_name='WARSZTAT'
) then
drop index WARSZTAT.WARSZTAT_PK
end if;
if exists(
select 1 from sys.systable
where table_name='WARSZTAT'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table WARSZTAT
end if;
/*==============================================================*/
/* Table: Kierowca */
/*==============================================================*/
create table Kierowca
(
ID_KLUBU integer not null,
ID_KIEROWCY integer not null,
IMIE long varchar null,
NAZWISKO long varchar null,
URODZINY date null,
WYGRANE integer null,
PRZEGRANE integer null,
constraint PK_KIEROWCA primary key (ID_KLUBU, ID_KIEROWCY)
);
/*==============================================================*/
/* Index: Kierowca_PK */
/*==============================================================*/
create unique index Kierowca_PK on Kierowca (
ID_KLUBU ASC,
ID_KIEROWCY ASC
);
/*==============================================================*/
/* Index: Zawodnicy_FK */
/*==============================================================*/
create index Zawodnicy_FK on Kierowca (
ID_KLUBU ASC
);
/*==============================================================*/
/* Table: Kluby */
/*==============================================================*/
create table Kluby
(
ID_KLUBU integer not null,
NAZWA_K long varchar null,
ZAWODNIK long varchar null,
MIEJSCE integer null,
constraint PK_KLUBY primary key (ID_KLUBU)
);
/*==============================================================*/
/* Index: Kluby_PK */
/*==============================================================*/
create unique index Kluby_PK on Kluby (
ID_KLUBU ASC
);
/*==============================================================*/
/* Table: Samochod */
/*==============================================================*/
create table Samochod
(
ID_KLUBU integer not null,
WAR_ID_KLUBU integer not null,
ID_WARSZTATU integer not null,
ID_AUTA integer not null,
MARKA long varchar null,
MODEL long varchar null,
KOLOR long varchar null,
POJEMNOSC_SILNIKA float(10) null,
MOC float(10) null,
ROK_PROD date null,
constraint PK_SAMOCHOD primary key (ID_KLUBU, WAR_ID_KLUBU, ID_WARSZTATU, ID_AUTA)
);
/*==============================================================*/
/* Index: Samochod_PK */
/*==============================================================*/
create unique index Samochod_PK on Samochod (
ID_KLUBU ASC,
WAR_ID_KLUBU ASC,
ID_WARSZTATU ASC,
ID_AUTA ASC
);
/*==============================================================*/
/* Index: Auta_FK */
/*==============================================================*/
create index Auta_FK on Samochod (
ID_KLUBU ASC
);
/*==============================================================*/
/* Index: Miejsce_FK */
/*==============================================================*/
create index Miejsce_FK on Samochod (
WAR_ID_KLUBU ASC,
ID_WARSZTATU ASC
);
/*==============================================================*/
/* Table: WARSZTAT */
/*==============================================================*/
create table WARSZTAT
(
ID_KLUBU integer not null,
ID_WARSZTATU integer not null,
POJEMNOSC integer null,
NAZWA_W long varchar null,
constraint PK_WARSZTAT primary key (ID_KLUBU, ID_WARSZTATU)
);
/*==============================================================*/
/* Index: WARSZTAT_PK */
/*==============================================================*/
create unique index WARSZTAT_PK on WARSZTAT (
ID_KLUBU ASC,
ID_WARSZTATU ASC
);
/*==============================================================*/
/* Index: Naprawa_FK */
/*==============================================================*/
create index Naprawa_FK on WARSZTAT (
ID_KLUBU ASC
);
alter table Kierowca
add constraint FK_KIEROWCA_ZAWODNICY_KLUBY foreign key (ID_KLUBU)
references Kluby (ID_KLUBU)
on update restrict
on delete restrict;
alter table Samochod
add constraint FK_SAMOCHOD_AUTA_KLUBY foreign key (ID_KLUBU)
references Kluby (ID_KLUBU)
on update restrict
on delete restrict;
alter table Samochod
add constraint FK_SAMOCHOD_POBYT_WARSZTAT foreign key (WAR_ID_KLUBU, ID_WARSZTATU)
references WARSZTAT (ID_KLUBU, ID_WARSZTATU)
on update restrict
on delete restrict;
alter table WARSZTAT
add constraint FK_WARSZTAT_NAPRAWA_KLUBY foreign key (ID_KLUBU)
references Kluby (ID_KLUBU)
on update restrict
on delete restrict;