-- első kollokvium - MINTA - 2014-11-16 create database Kereskedőház; go use Kereskedőház; go -- Adatbázis és tábláinak létrehozása create table ARU ( ARU_AZON int not null primary key, ARUNEV char(25) not null, ARU_LEIRAS varchar(500) null ) go create table DOLGOZO ( DOLGOZO_AZONOSITO int not null primary key, JMBG numeric(13) not null, VEZETEKNEV char(15) not null, KERESZTNEV char(15) not null, SZULETETT datetime not null, MIOTA_DOLGOZONK datetime not null, LAKCIM_VAROS char(15) null, LAKCIM_UTCA_HSZ char(15) null ) go create table SZAMLA ( SZLA_SZAM int not null primary key, DOLGOZO_AZONOSITO int not null foreign key references DOLGOZO (DOLGOZO_AZONOSITO), SZLA_KELTE datetime not null, SZLA_VEGOSSZEGE money not null, FIZETESI_HATARIDO datetime not null, KAPCSOLATTARTO char(30) null, TELEFON char(20) null ) go create table SZAMLA_TETEL ( SZLA_SZAM int not null foreign key references SZAMLA (SZLA_SZAM), SZLA_TETEL_SZAM int not null, ARU_AZON int not null foreign key references ARU (ARU_AZON), MENNYISEG decimal(12,2) not null, EGYSEG char(15) not null, EGYSEGAR decimal(12,2) not null, constraint PK_SZAMLA_TETEL primary key nonclustered (SZLA_SZAM, SZLA_TETEL_SZAM) ) go -- Adatbázis és tábláinak létrehozása -- 2./ alter table aru add aru_hasznalhatosagi_datuma date default getdate() check (aru_hasznalhatosagi_datuma>getdate()); go -- 3./ alter table szamla alter column kapcsolattarto varchar(25) not null; go -- 4./ alter table szamla_tetel add constraint uc_egysegar_kontroll check (egysegar>=10); go -- 5./ insert DOLGOZO values (1,1411955820030,'Imre', 'Petkovics','1955.11.14', '1993.09.01', 'Subotica', 'Rumska 17'); go select * from DOLGOZO; go update DOLGOZO set VEZETEKNEV='Petkovics', keresztnev='Imre'; go insert ARU values (1,'Gyömbér','Erősítőszer','2016.02.15'); go select * from ARU; go insert SZAMLA values(1,1,GETDATE(),237.54,'2014.11.09','Petkovics Györgyi','+381656557498'); go select * from SZAMLA; go insert SZAMLA_TETEL values(1,1,1,1,'Kg',890.00); go select * from SZAMLA_TETEL; go -- 6./ alter table szamla_tetel nocheck constraint uc_egysegar_kontroll; go update SZAMLA_TETEL set EGYSEGAR=5; go alter table szamla_tetel check constraint uc_egysegar_kontroll; go update SZAMLA_TETEL set EGYSEGAR=3; go --7./ delete SZAMLA_TETEL where EGYSEGAR<10; go select * from SZAMLA_TETEL; go -- 8./ alter table szamla_tetel drop constraint uc_egysegar_kontroll; go -- 9./ create view dolgozonezet as (select vezeteknev, keresztnev, jmbg, dolgozo_azonosito, lakcim_varos from DOLGOZO); go select * from dolgozonezet; go