0% found this document useful (0 votes)
6 views

Freelancer management system (1)

The document outlines a Freelancer Website Management System, detailing the relationships between buyers, sellers, clients, and payments, including their unique identifiers and attributes. It includes normalization steps for various entities and provides SQL commands for creating tables, inserting data, and querying the database. The document also features examples of subqueries and joins to retrieve specific data from the database.

Uploaded by

Jamilur Reza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Freelancer management system (1)

The document outlines a Freelancer Website Management System, detailing the relationships between buyers, sellers, clients, and payments, including their unique identifiers and attributes. It includes normalization steps for various entities and provides SQL commands for creating tables, inserting data, and querying the database. The document also features examples of subqueries and joins to retrieve specific data from the database.

Uploaded by

Jamilur Reza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Final Assignment

Introduction to Database

Freelancer Website Management System

Scenerio

In a Freelancer website Management system Buyer has a


unique buyer id(primary key), a buyer city, country and
multiple phone number. Multiple buyer works freelancer
website with seller. Each seller has a unique seller id(primary
key), seller name, phone number and multiple
skill(freelancer, buyer & seller where all these relations are
many to many relation). Each multiple seller contest each to
another client. It has a unique client id(primary key), email,
tips and name(seller, contest & client where all these relations
are one to many relation). Client order by buyer then they
give him payment document. Each buyer order relation by
each Payment. Payment has a payment amount, payment date
and unique payment id (primary key). Here buyer, payment &
order are in many to many relation.
ER Diagram
In a Freelancer website Management system Buyer has a unique buyer id, a buyer city, country and multiple
phone number. Multiple buyer works freelancer website with seller.

Each seller has a unique seller id, seller name, phone number and multiple skill.
In a Freelancer website Management system Buyer has a unique buyer id, a buyer city,
country and multiple phone number. Multiple buyer works freelancer website with
seller. Each seller has a unique seller id, seller name, phone number and multiple skill.
(freelancer, buyer & seller where all these relations are many to many relation).

Each multiple seller contest each to another client. It has a unique id, email, tips and
name.
In a Freelancer website Management system Buyer has a unique buyer id, a buyer city,
country and multiple phone number. Multiple buyer works freelancer website with
seller. Each seller has a unique seller id, seller name, phone number and multiple skill.
Each multiple seller contest each to another client. It has a unique client id, email, tips
and name ( seller, contest & client where all these relations are one to many relation).
Each buyer order relation by each Payment. Payment has a payment amount, payment date and payment
unique id (primary key).

In a Freelancer website Management system Buyer has a unique buyer id(primary


key), a buyer city, country and multiple phone number. Multiple buyer works
freelancer website with seller. Each seller has a unique seller id(primary key), seller
name, phone number and multiple skill. Each multiple seller contest each to another
client. It has a unique id, email, tips and name. Client order by buyer then they give
him payment document. Each buyer order relation by each Payment. Payment has a
payment amount, payment date and unique payment id. Here buyer, payment & order
are in many to many relation.
Normalization

Freelancer ( B_id , B_name , city , country , B_phone , S_id , S_name , S_phone , skill )
1NF: B_phone , skill are multivalued
2NF: B_id , B_name , city , country , B_phone
S_id , S_name , S_phone , skill
3NF: B_id , B_name ,B_phone
L_id , city , country
S_id , S_name , S_phone , skill
Table for Freelancer:
1. B_id , B_name , L_id , S_id
2. L_id , city , country
3. S_id , S_name , S_phone
4. B_id , B_phone
5. S_id , skill

Order ( B_id , B_name , city , country , B_phone ,P_id , P_amount , P_date )


1NF: B_phone are multivalued
2NF: B_id , B_name , city , country , B_phone
P_id , P_amount , P_date
3NF: B_id , B_name ,B_phone
E_id , city , country
P_id , P_amount , P_date
Table for Order:
1. B_id , B_name , E_id , P_id
2. E_id , city , country
3. P_id , P_amount , P_date
4. B_id , B_phone

Contest ( S_id , S_name , S_phone , skill ,C_id , C_name , tips , e-mial )


1NF: Skill , e-mail are multivalued
2NF: S_id , S_name , S_phone , skill
C_id , C_name , tips , e-mial

3NF: no transitive dependency


S_id , S_name , S_phone , skill
C_id , C_name , tips , e-mial
Table for Contest:
1. S_id , S_name , S_phone , C_id
2. C_id , C_name , tips
3. S_id , Skill
4. C_id , e-mail

Final Table:
1. B_id , B_name , L_id , S_id
2. L_id , city , country
3. S_id , S_name , S_phone
4. B_id , B_phone
5. S_id , skill
6. B_id , B_name , E_id , P_id
7. E_id , city , country
8. P_id , P_amount , P_date
9. S_id , S_name , S_phone , C_id
10. C_id , C_name , tips
11. C_id, Email
Create Table
create table byer(
b_id number(12) primary key,
b_name varchar2(18),
l_id number(12),
s_id number(12))
alter table byer add constraint ax1 foreign key(l_id)references bio_byer(l_id)
alter table byer add constraint ax2 foreign key(s_id)references seller(s_id)

create table bio_byer(


l_id number(12),
city varchar2(8),
country varchar2(10))
alter table bio_byer add constraint aze1 primary key(l_id)
create table seller(
s_id number(12),
s_name varchar2(18),
s_phone number(11))
alter table seller add constraint aze2 primary key(s_id)

create table byer_num(


b_id number(12),
b_phone number(11))
alter table byer_num add constraint aze3 primary key(b_id,b_phone)
create table seller_lang(
s_id number(12),
skill varchar2(18))
alter table seller_lang add constraint aze4 primary key(s_id,skill)

create table byer_1(


b_id number(12),
b_name(12),
e_id number(12),
p_id number(12))
alter table byer_1 add constraint aze5 primary key(b_id)
Alter table byer_1 add constraint ax3 foreign key(e_id)references bio_byer1(e_id)
Alter table byer_1 add constraint az9 foreign key(p_id)references payment(p_id)
create table bio_byer1(
e_id number(12),
city varchar2(8),
country varchar2(10))
alter table bio_byer1 add constraint azew primary key(e_id)

create table payment(


p_id number(12),
p_amount decimal(8,2),
p_date date (7))
alter table payment add constraint aze7 primary key(p_id)

create table seller2(


s_id number(12),
s_name varchar2(18),
s_phone number(11),
c_id number(12))
alter table seller2 add constraint aze8 primary key(s_id)
Alter table seller2 add constraint ax5 foreign key(c_id)references client(c_id)

create table client(


c_id number(12),
c_name varchar2(18),
tips decimal(8,2))
alter table client add constraint aze9 primary key(c_id)
create table bio_client(
c_id number(12),
email varchar2(30))
alter table bio_client add constraint aze10 primary key(c_id,email)

Data Insertion
insert into byer values(1001,'Alif',2001,3001)
insert into byer values(1002,'Rana',2002,3002)
insert into byer values(1003,'Fariad',2003,3003)
insert into byer values(1004,'Niloy',2004,3004)

insert into bio_byer values(2001,'Dhaka','Bangladesh')


insert into bio_byer values(2002,'Delhi','India')
insert into bio_byer values(2003,'Riyadh','Saudi Arab')
insert into bio_byer values(2004,'New york','America')

insert into seller values(3001,'Reza',01727346924 )


insert into seller values(3002,'Mehedi',01825346923 )
insert into seller values(3003,'Bristy',01925346927 )
insert into seller values(3004,'Sabbir',01522346928 )

insert into byer_num values(1001,01726546926 )


insert into byer_num values(1001,01623543929 )
insert into byer_num values(1002,01526546923 )
insert into byer_num values(1003,01826546921 )
insert into byer_num values(1004,01526546920 )

insert into seller_lang values(3001,'Bangla' )


insert into seller_lang values(3001,'English' )
insert into seller_lang values(3002,'Hindi' )
insert into seller_lang values(3003,'Arbi' )
insert into seller_lang values(3004,'English' )

insert into byer_1 values(1001,'Alif',4001,5001)


insert into byer_1 values(1002,'Rana',4002,5002)
insert into byer_1 values(1003,'Fariad',4003,5003)
insert into byer_1 values(1004,'Niloy',4004,5004)

insert into bio_byer1 values(4001,'Dhaka','Bangladesh')


insert into bio_byer1 values(4002,'Delhi','India')
insert into bio_byer1 values(4003,'Riyadh','Saudi Arab')
insert into bio_byer1 values(4004,'New york','America')

insert into payment values(5001,20000.00,'4-jan-20')


insert into payment values(5002,30000.00,'14-jun-20')
insert into payment values(5003,25000.00,'20-feb-20')
insert into payment values(5004,29000.00,'18-jan-20')
insert into seller2 values(3001,'Reza',01727346924,7001 )
insert into seller2 values(3002,'Bristy',01825346923,7002 )
insert into seller2 values(3003,'Mehedi',01925346927,7003 )
insert into seller2 values(3004,'Sabbir',01522346928,7004 )

insert into client values(7001,'Abir',1000.00 )


insert into client values(7002,'Mahadi',1500.00 )
insert into client values(7003,'Uchassh',1200.00 )
insert into client values(7004,'Shoaib',1700.00 )
insert into bio_client values(7001,'[email protected]' )
insert into bio_client values(7002,'[email protected]')
insert into bio_client values(7003,'[email protected]' )
insert into bio_client values(7004,'[email protected]' )

Subquery
1. Display all id, amount & date from payment where payment amount is equal to maximum
amount.
select p_id, p_amount, p_date
from payment
where p_amount in (select max(p_amount) from payment)
2. Display all id, name & tips from client where tips is equal to minimum tips.
select c_id, c_name, tips
from client
where tips = (select min(tips) from client)
3. Display all id, name, phone number & date from seller2 where seller name is related to
client id=7002.
select s_id, s_name, s_phone, c_id
from seller2
where s_name = (select s_name from seller2 where c_id=7002)

4. Display all b_id, name & l_id, s_id from byer where byer name is related to byer id=1003.
select b_id, b_name, l_id, s_id
from byer
where b_name in (select b_name from byer where b_id=1003)
Joining
5. Get all byer id, name & country from both tables byer_1 & bio_byer1 and city in Dhaka.
select b_id,b_name,country
from byer_1,bio_byer1
where byer_1.e_id(+)=bio_byer1.e_id and city='Dhaka'

6. Select seller name, id & byer name from byer & seller tables who has seller id=3001.
select s_name,b_name,byer.s_id
from byer,seller
where byer.s_id=seller.s_id
and byer.s_id=3001

7. Select seller id, name & client id where seller has the phone number= 1925346927.
select a.s_id,b.s_name,b.c_id
from seller2 a, seller2 b
where a.s_id=b.s_id and a.s_phone=1925346927

View
8. Create a view called test_view based on payment id, payment amount from payment table
where payment amount is equal to minimum amount.
create view test_view
(name, min_amount)
as select b.p_id, MIN(p.p_amount)
from payment b, payment p
where b.p_id = p.p_id
group by b.p_id

You might also like