Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

A Report

On the work done during 3rd semester subject


Database Management Systems
of
B.Tech. Computer Engineering

Mini Instagram

Prepared by: Prepared by:


Name - SARAIYA MEET R Name - SHAH MEET J
ID - 21ceusg102 ID - 21ceuos086
Roll No - CE108 Roll No - CE111
Computer Engineering, Computer Engineering,
Dharmsinh Desai University Dharmsinh Desai University

Dharmsinh Desai University


October 2022
Table of Content

● Introduction - Mini Instagram


● E-R Diagram
● Schema
● Schema Diagram
● Create, Insert, Update and Delete (CRUD) Queries
● Complex Queries
● References
Brief information about the system
A social media platform known as Mini Instagram. The application is a simple way to communicate with
friends and family located all over the world.

The basic features of the applications are to add your photos not just pictures but add a description on
what the photo is about. The photos uploaded are seen by the followers who are the friends of family
members. Followers send a simple request to their dear ones by one click. The pictures are liked by the
followers and if the account is no longer needed it is deactivated by the user.
ER Diagram
Schema
create table users(
user_id varchar(12) not null,
pass varchar(20) not null,
fullname varchar(40) not null,
dp_url varchar(150) null default null,
bio varchar(100) null default null,
primary key (user_id)
);

CREATE TABLE followers (


user_id VARCHAR(30) NOT NUll,
follower_id VARCHAR(30) NOT null,
PRIMARY KEY (user_id, follower_id)
CONSTRAINT f1
FOREIGN KEY (user_id) REFERENCES users (user_id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT f2
FOREIGN KEY (follower_id) REFERENCES users (user_id)
ON DELETE CASCADE
ON UPDATE CASCADE
);

CREATE TABLE photos


(
photo_id INT AUTO_INCREMENT NOT NULL,
image_url VARCHAR(150) NULL DEFAULT NULL,
caption VARCHAR(30) NULL DEFAULT NULL,
PRIMARY KEY (photo_id)
);

CREATE TABLE photo_of (


user_id VARCHAR(30) NOT NULL,
photo_id INT(10) NOT NULL,
PRIMARY KEY (user_id, photo_id),
CONSTRAINT fk5 FOREIGN KEY (user_id) REFERENCES users (user_id)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT fk6 FOREIGN KEY (photo_id) REFERENCES photos (photo_id)
ON DELETE CASCADE ON UPDATE CASCADE)
);
CREATE TABLE likes
(
photo_id INT(10,0) Not null,
liker_id VARCHAR(30) NOT NUll,
PRIMARY KEY (photo_id, liker_id),
CONSTRAINT fk7
FOREIGN KEY (photo_id) REFERENCES photos (photo_id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT fk8
FOREIGN KEY (liker_id) REFERENCES users (user_id)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CRUD
insert into users values('mi111111','1234','mann_shah',

'https://i.pinimg.com/originals/c1/f7/1c/c1f71c95058915eaa22cc0f82a786696.jpg','I am boy');

insert into users values('mi111116','1111','meet_sariya',

'https://th.bing.com/th/id/OIP.m_YMQqQpBI_mWGQHLts56gHaKT?pid=ImgDet&w=208&h=289&c=7&d
pr=1.5','I am nature lover');

insert into users values('mi111113','1712','jay_patel',

'https://www.bing.com/images/search?view=detailV2&ccid=ICyrNxnL&id=3E2541D919062D395B07599
58E23BB7078F99DD1&thid=OIP.ICyrNxnLUOlSt3-fMrM-QQHaEK&mediaurl ','I am superstar');

insert into users values('mi111114','5555','heet_parekh',


'https://i.pinimg.com/736x/02/31/ca/0231ca8ca7728f5e3cfd434f7f772071--damien-sargue-drawing-pra
ctice.jpg','I am hero' );

insert into users values('mi111115','3819','jeet_shaikh',


'https://www.bing.com/ck/a?!&&p=3822544c2bdc2a3fJmltdHM9MTY2NzY5MjgwMCZpZ3VpZD0yNjU0N
GU4NC04MDczLTYzMTYtMDQ0O.jpg','I am animal lover');
Users
user p fullna dp_url
_id a me
ss

mi1 1 mann https://i.pinimg.com/originals/c1/f7/1c/c1f71c95058915eaa22cc0f82a786696.jpg


111 2 _shah
11 3
4

mi1 1 meet https://th.bing.com/th/id/OIP.m_YMQqQpBI_mWGQHLts56gHaKT?pid=ImgDet&w=20


111 1 _sariy 8&h=289&c=7&dpr=1.5
16 1 a
1
mi1 1 jay_p https://www.bing.com/images/search?view=detailV2&ccid=ICyrNxnL&id=3E2541D91
111 7 atel 9062D395B0759958E23BB7078F99DD1&thid=OIP.ICyrNxnLUOlSt3-fMrM-QQHaEK&m
13 1 ediaurl
2

mi1 5 heet_ https://i.pinimg.com/736x/02/31/ca/0231ca8ca7728f5e3cfd434f7f772071--damien-sa


111 5 parek rgue-drawing-practice.jpg
14 5 h
5

mi1 3 jeet_s https://www.bing.com/ck/a?!&&p=3822544c2bdc2a3fJmltdHM9MTY2NzY5MjgwMCZ


111 8 haikh pZ3VpZD0yNjU0NGU4NC04MDczLTYzMTYtMDQ0O.jpg
15 1
9

INSERT INTO `followers`values('mi111111','mi111113');


INSERT INTO `followers`values('mi111111','mi111113');
INSERT INTO `followers`values('mi111111','mi111114');
INSERT INTO `followers`values('mi111114','mi111111');
INSERT INTO `followers`values('mi111114','mi111111');
INSERT INTO `followers`values('mi111115','mi111114');
INSERT INTO `followers`values('mi111115','mi111111');
INSERT INTO `followers`values('mi111115','mi111116');

INSERT INTO `photos`(`photo_id`, `image_url`, `caption`) VALUES


('5','https://www.bing.com/ck/a?!&&p=3822544c2bdc2a3fJmltdHM9MTY2NzY5MjgwMCZpZ3V
pZD0yNjU0NGU4NC04MDczLTYzMTYtMDQ0O.jpg','i am rocky');
INSERT INTO `photos`(`photo_id`, `image_url`, `caption`) VALUES
('1','https://i.pinimg.com/originals/c1/f7/1c/c1f71c95058915eaa22cc0f82a786696.jpg','i am
boy');
INSERT INTO `photos`(`photo_id`, `image_url`, `caption`) VALUES
('2','https://www.bing.com/ck/a?!&&p=3822544c2bdc2a3fJmltdHM9MTY2NzY5MjgwMCZpZ3V
pZD0yNjU0NGU4NC04MDczLTYzMTYtMDQ0O.jpg','i am rocky');
INSERT INTO `photos`(`photo_id`, `image_url`, `caption`) VALUES
('3','https://www.bing.com/ck/a?!&&p=3822544c2bdc2a3fJmltdHM9MTY2NzY5MjgwMCZpZ3V
pZD0yNjU0NGU4NC04MDczLTYzMTYtMDQ0O.jpg','i am rocky');
INSERT INTO `photos`(`photo_id`, `image_url`, `caption`) VALUES
('4','https://www.bing.com/ck/a?!&&p=3822544c2bdc2a3fJmltdHM9MTY2NzY5MjgwMCZpZ3V
pZD0yNjU0NGU4NC04MDczLTYzMTYtMDQ0O.jpg','i am rocky');

Complex Queries:-

select photo_id,image_url
from photos natural join photo_of
where user_id in
(select following_id
from following
where user_id = username
);

select fullname,substring_index(image_url, '/', -1) as imgg


from (users join likes on user_id = liker_id) natural join photos where photo_id in
(select photo_id
from photos natural join photo_of
where user_id= username);
References
● https://www.freeprojectz.com/
(Reference of E-R Diagram)
● https://livesql.oracle.com/
(Online SQL compiler)
•https://www.programiz.com/sql/online-compiler/
● Queries formation is done by us.

● E - R Diagram was created from - diagrams.net

You might also like