Tải bản đầy đủ (.docx) (14 trang)

BÀI TẬP LỚN MÔN CSDL NÂNG CAO ĐT: QL công tác SV tình nguyện mùa hè xanh

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (54.4 KB, 14 trang )

BÀI TẬP LỚN MƠN CSDL NÂNG CAO
ĐT: QL cơng tác SV tình nguyện mùa hè xanh

SV (MSSV, HỌ, TÊN, PHÁI, NĂM_SINH, MÃ_LỚP, MÃ_KHOA)
KHOA (MÃ_KHOA, TÊN_KHOA)
ẤP (MÃ_ẤP, TÊN_ẤP, MÃ_PHG_XÃ)
PHƯỜNG_XÃ (MÃ_PHG_XÃ, TÊN_ PHG_XÃ, MÃ_QUẬN_H)
QUẬN_H (MÃ_QUẬN_H, TÊN_QUẬN_H, MÃ_TỈNH_TP)
TỈNH_TP (MÃ_TỈNH_TP, TÊN_ TỈNH_TP)
PHÂN_BỔ (MSSV, NĂM, MÃ_ẤP)
CÔNG_TÁC (MÃ_CTÁC, DGIẢI)
NHẬN_CTÁC (MSSV, NĂM, MÃ_CTÁC, CHẤT_LG)
THÀNH_QUẢ (MÃ_ẤP, MÃ_ CTÁC, NĂM, SỐ_LG)

1. Tìm Khoa có nhiều SV tham gia mùa hè xanh nhất trong hè 2006.
2. Tìm tổng số cầu đã được xây trong huyện Cờ đỏ, TP Cần thơ đối với cơng tác
“Xây cầu cho vùng sâu”.
3. Tìm mã, họ tên, phái, năm sinh, tên lớp và tên khoa của SV luôn đạt chất lượng
xuất sắc trong mọi công tác ở mùa hè xanh 2005.
4. Tìm xã được phân bổ ít SV nhất từ xưa đến nay.
5. Tìm diễn giải cho các chỉ tiêu đã đưa về cho ấp Tân thanh, xã Tân hạnh, huyện
Long hồ, tỉnh Vĩnh long.
6. Tìm các cơng tác mà SV có mã số 1032593 đã nhận trong mỗi mùa hè.
7. Tìm số SV đã có đóng góp vào cơng tác gặt lúa chạy lũ ở những ấp có thành quả
gặt được hơn 1000 héc ta trong mùa hè năm 2007 ở tỉnh Thừa thiên-Huế.
8. Tìm tổng số SV đã phân bổ cho mỗi huyện của tỉnh Trà vinh.
9. Tìm tỷ lệ SV được nhận công tác phổ cập tin học so với tổng số SV phân bổ về
tỉnh Sóc trăng.
10. Tìm tên các xã và tên huyện, tỉnh tương ứng được phân bổ SV về cơng tác
phịng ngừa dịch H5N1 trong 2 năm liên tiếp.



BẢNG 1: THÔNG TIN SINH VIÊN
Bước 1:
Create or replace type Sinhvien_type as object (
masv varchar2 (10),
tensv nvarchar2 (50),
gioitinh varchar2 (5),
ngaysinh date,
malop varchar2 (10),
thuockhoa ref Khoa_type,
member function get_masv return varchar2,
member function get_tensv return nvarchar2,
member function get_gioitinh return varchar2,
member function get_ngaysinh return date,
member function get_malop return varchar2,
member function get_thuockhoa return Khoa_type,
static procedure set_hoten (bienmasv varchar2, bienhoten nvarchar2),
static procedure set_ngaysinh (bienmasv varchar2, bienngaysinh date),
static function tongsv return integer is
tong integer;
begin
select count (*) into tong from Sinhvien;
return tong;
end tongsv;
);
Bước 2:
Create table Sinhvien of Sinhvien_type (


Primary key (masv),

tensv not null,
gioitin not null,
ngaysinh not null
);
Bước 3:
Insert into Sinhvien values (‘TH01’,’Nguyen Van A’, ’Nam’,
to_date(‘01/01/1990’, ‘dd/mm/yyyy’, ‘TINHOC’), (select ref(kh) from khoa kh
where makh = 'TH'));
Insert into Sinhvien values (‘TH02’,’Nguyen Van B’, ‘Nam’,
to_date(‘02/02/1992’, ‘dd/mm/yyyy’, ‘TINHOC’), (select ref(kh) from khoa kh
where makh = 'TH'));
Insert into Sinhvien values (‘AV01’,’Tran Thi Tuyet’, ’Nu’,
to_date(‘01/01/1989’, ‘dd/mm/yyyy’, ‘ANHVAN’), (select ref(kh) from khoa kh
where makh = 'AV'));
Insert into Sinhvien values (‘AV02’,’Le Tuyet Ngoc’, ’Nu’,
to_date(‘04/11/1990’, ‘dd/mm/yyyy’, ‘ANHVAN’), (select ref(kh) from khoa kh
where makh = 'AV'));
Insert into Sinhvien values (‘KT01’,’Nguyen Van A’, ‘Nam’,
to_date(‘01/01/1990’, ‘dd/mm/yyyy’, ‘KETOAN’), (select ref(kh) from khoa kh
where makh = 'KT'));
Insert into Sinhvien values (‘KT02’,’Dang Thi Lam’,’Nu’,
to_date(‘01/03/1990’, ‘dd/mm/yyyy’, ‘KETOAN’), (select ref(kh) from khoa kh
where makh = 'KT'));
Bước 4:
Create or replace type body Sinhvien as
member function get_masv return varchar2 is
begin
return masv;



end get_masv;
member function get_tensv return nvarchar2 is
begin
return tensv;
end get_tensv;
member function get_gioitinh return varchar2 is
begin
return gioitinh;
end get_gioitinh;
member function get_ngaysinh return nvarchar2 is
begin
return ngaysinh;
end get_ ngaysinh;
end;


BẢNG 2: KHOA
Bước 1:
create or replace type Khoa_type as object (
makh varchar2(5),
tenkh nvarchar2(50),
member function get_makh return varchar2,
member function get_tenkh return nvarchar2 ,
static procedure set_tenkh (bienmakh varchar2,
bientenkh nvarchar2),
static function tong_kh return integer,
static procedure inds_kh
);
Bước 2:
create table Khoa of Khoa_type (

primary key (makh),
tenkh unique
);
Bước 3:
insert into Khoa values ('AV','Anh van');
insert into Khoa values ('TH','Tin hoc');
insert into Khoa values ('KT','Ke toan');
Bước 4:
create or replace type body Khoa_type as
member function get_makh return varchar2 is
begin
return makh;


end get_makh;
member function get_tenkh return nvarchar2 is
begin
return tenkh;
end get_tenkh;
static procedure set_tenkh (bienmakh varchar2, bientenkh nvarchar2) is
begin
update khoa

set tenkh = bientenkh

end set_tenkh;
static function tong_kh return integer is
tong integer;
begin
select count(*) into tong from khoa;

return tong;
end tong_kh;
end;

where makh = bienmakh;


BẢNG 3: ẤP
Bước 1:
Create or replace type Ap_type as object (
maap varchar2 (10),
tenap nvarchar2 (50),
thuocphuongxa ref Phuongxa_type,
member function get_maap return varchar2,
member function get_tenap return nvarchar2,
member function get_thuocphuongxa return Xa_type,
static procedure set_tenap (bienmaap varchar2, bientenap nvarchar2)
);
Bước 2:
Create table Ap of Ap_type (
Primary key (maap),
tenap not null
);
Bước 3:
Insert into Ap values (‘BL01’,’Long Thanh’,(select ref(px) from Phuongxa
px where maxa = '95TTPL'));
Insert into Ap values (‘BL02’,’Long Hau’,(select ref(px) from Phuongxa px
where maxa = '95TTPL'));
Insert into Ap values (‘BL03’,’My Tan’,(select ref(px) from Phuongxa px
where maxa = '95VPD'));

Insert into Ap values (‘ST01’,’Hung Hoi’,(select ref(px) from Phuongxa px
where maxa = '59TTHH'));
Insert into Ap values (‘ST02’,’Khom 1’,(select ref(px) from Phuongxa px
where maxa = '59PHUONG2'));


Insert into Ap values (‘CT01’,’So 4’,(select ref(px) from Phuongxa px where
maxa = '55MYKHANH'));
Insert into Ap values (‘CT02’,’So 8’,(select ref(px) from Phuongxa px where
maxa = '55BINHTHUY'));
Bước 4:
Create or replace type body Ap as
member function get_maap return varchar2 is
begin
return maap;
end get_maap;
member function get_tenap return nvarchar2 is
begin
return tenap;
end get_tenap;
end;


BẢNG 4: PHƯỜNG (XÃ)
Bước 1:
Create or replace type Xa_type as object (
maxa varchar2 (10),
tenxa nvarchar2 (50),
thuocHuyen ref Huyen_type,
member function get_maxa return varchar2,

member function get_tenxa return nvarchar2,
member function get_thuochuyen return Huyen_type,
static procedure set_tenxa (bienmaxa varchar2, bientenxa nvarchar2)
);
Bước 2:
Create table Xa of Xa_type (
Primary key (maxa),
tenxa not null
);
Bước 3:
Insert into Xa values (‘95TTPL’,’Thi tran Phuoc Long’,(select ref(px) from
Huyen px where mahuyen = 'H01'));
Insert into Xa values (‘95VPD’,’Vinh Phu Dong’,(select ref(px) from Huyen
px where mahuyen = 'H01'));
Insert into Xa values (‘59TTHH’,’Thi tran Hung Hoi’,(select ref(px) from
Huyen px where mahuyen = 'H02'));
Insert into Xa values (‘59PHUONG2’,’Phuong 2’,(select ref(px) from
Huyen px where mahuyen = 'H03'));
Insert into Xa values (‘55MYKHANH'’,’My Khanh’,(select ref(px) from
Huyen px where mahuyen = 'H04’));


Insert into Xa values (‘55BINHTHUY’,’Binh Thuy’,(select ref(px) from
Huyen px where mahuyen = 'H05'));
Bước 4:
Create or replace type body Xa as
member function get_maxa return varchar2 is
begin
return maxa;
end get_maxa;

member function get_tenxa return nvarchar2 is
begin
return tenxa;
end get_tenxa;
end;


BẢNG 5: HUYỆN
Bước 1:
Create or replace type Huyen_type as object (
mahuyen varchar2 (10),
tenhuyen nvarchar2 (50),
thuocTinh ref Huyen_type,
member function get_mahuyen return varchar2,
member function get_tenhuyen return nvarchar2,
member function get_thuocTinh return Tinh_type,
static procedure set_tenhuyen (bienmahuyen varchar2, bientenhuyen
nvarchar2)
);
Bước 2:
Create table Huyen of Huyen_type (
Primary key (mahuyen),
tenhuyen not null
);
Bước 3:
Insert into Huyen values (‘H01’,’ Phuoc Long’,(select ref(px) from Tinh px
where matinh = '094'));
Insert into Huyen values (‘H02’,’Vinh Loi’,(select ref(px) from Tinh px
where matinh = '094'));
Insert into Huyen values (‘H03’,’ Thanh Pho Soc Trang’,(select ref(px) from

Tinh px where matinh = '083'));
Insert into Huyen values (‘H04’,’ Phong Dien’,(select ref(px) from Tinh px
where matinh = '065'));


Insert into Huyen values (‘H05’,’Binh Thuy’,(select ref(px) from Tinh px
where matinh = '065'));
Bước 4:
Create or replace type body Huyen as
member function get_mahuyen return varchar2 is
begin
return mahuyen;
end get_mahuyen;
member function get_tenhuyen return nvarchar2 is
begin
return tenhuyen;
end get_tenhuyen;
end;


BẢNG 6: TỈNH (TP)
Bước 1:
Create or replace type Tinh_type as object (
matinh varchar2 (10),
tentinh nvarchar2 (50),
member function get_matinh return varchar2,
member function get_tentinh return nvarchar2,
static procedure set_tentinh (bienmatinh varchar2, biententinh nvarchar2)
);
Bước 2:

Create table Tinh of Tinh_type (
Primary key (matinh),
tentinh not null
);
Bước 3:
Insert into Tinh values (‘094’,’ Bac Lieu’);
Insert into Tinh values (‘083’,’ Soc Trang’);
Insert into Tinh values (‘084’,’ Tra Vinh’);
Insert into Tinh values (‘065’,’ Can Tho’);
Bước 4:
Create or replace type body Tinh as
member function get_matinh return varchar2 is
begin
return matinh;
end get_matinh;
member function get_tentinh return nvarchar2 is


begin
return tentinh;
end get_tentinh;
end;



×