-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Oct 31, 2024 at 08:23 AM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `pushtalk`
--

-- --------------------------------------------------------

--
-- Table structure for table `blockedtable`
--

CREATE TABLE `blockedtable` (
  `id` int(250) NOT NULL,
  `blockedBy` varchar(250) NOT NULL,
  `userBlocked` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `chat`
--

CREATE TABLE `chat` (
  `id` int(11) NOT NULL,
  `sender_email` varchar(250) NOT NULL,
  `receiver_email` varchar(250) NOT NULL,
  `message` text NOT NULL,
  `type` varchar(5) NOT NULL,
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `friend_table`
--

CREATE TABLE `friend_table` (
  `id` int(11) NOT NULL,
  `user_email` varchar(250) NOT NULL,
  `friend_email` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `groupmembertable`
--

CREATE TABLE `groupmembertable` (
  `groupMemberId` int(250) NOT NULL,
  `groupId` int(250) NOT NULL,
  `userEmail` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `groupmessagetable`
--

CREATE TABLE `groupmessagetable` (
  `messageId` int(250) NOT NULL,
  `groupId` int(250) NOT NULL,
  `senderEmail` varchar(250) NOT NULL,
  `messageContent` varchar(1000) NOT NULL,
  `messageType` varchar(250) NOT NULL,
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `grouptable`
--

CREATE TABLE `grouptable` (
  `groupId` int(250) NOT NULL,
  `groupName` varchar(250) NOT NULL,
  `groupOwnerEmail` varchar(250) NOT NULL,
  `groupProfile` varchar(1000) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `mutefriendstable`
--

CREATE TABLE `mutefriendstable` (
  `id` int(250) NOT NULL,
  `userEmail` varchar(250) NOT NULL,
  `friendEmail` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `requests`
--

CREATE TABLE `requests` (
  `id` int(11) NOT NULL,
  `sender_email` varchar(250) NOT NULL,
  `reciever_email` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `id` int(11) NOT NULL,
  `name` varchar(30) NOT NULL,
  `email` varchar(250) NOT NULL,
  `image` text NOT NULL,
  `fcm` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `userstatus`
--

CREATE TABLE `userstatus` (
  `statusId` int(250) NOT NULL,
  `userEmail` varchar(250) NOT NULL,
  `status` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `blockedtable`
--
ALTER TABLE `blockedtable`
  ADD PRIMARY KEY (`id`),
  ADD KEY `blockby` (`blockedBy`),
  ADD KEY `userblocked` (`userBlocked`);

--
-- Indexes for table `chat`
--
ALTER TABLE `chat`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_user_email` (`sender_email`),
  ADD KEY `user_with_email` (`receiver_email`);

--
-- Indexes for table `friend_table`
--
ALTER TABLE `friend_table`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_name_with_user_email` (`user_email`),
  ADD KEY `friend_email_with_user_email` (`friend_email`);

--
-- Indexes for table `groupmembertable`
--
ALTER TABLE `groupmembertable`
  ADD PRIMARY KEY (`groupMemberId`),
  ADD KEY `av` (`groupId`),
  ADD KEY `ab` (`userEmail`);

--
-- Indexes for table `groupmessagetable`
--
ALTER TABLE `groupmessagetable`
  ADD PRIMARY KEY (`messageId`),
  ADD KEY `x` (`groupId`),
  ADD KEY `y` (`senderEmail`);

--
-- Indexes for table `grouptable`
--
ALTER TABLE `grouptable`
  ADD PRIMARY KEY (`groupId`),
  ADD KEY `groupOwnerContraint` (`groupOwnerEmail`);

--
-- Indexes for table `mutefriendstable`
--
ALTER TABLE `mutefriendstable`
  ADD PRIMARY KEY (`id`),
  ADD KEY `abc` (`userEmail`),
  ADD KEY `def` (`friendEmail`);

--
-- Indexes for table `requests`
--
ALTER TABLE `requests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `req` (`sender_email`),
  ADD KEY `reqs` (`reciever_email`);

--
-- Indexes for table `user`
--
ALTER TABLE `user`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`);

--
-- Indexes for table `userstatus`
--
ALTER TABLE `userstatus`
  ADD PRIMARY KEY (`statusId`),
  ADD KEY `acv` (`userEmail`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `blockedtable`
--
ALTER TABLE `blockedtable`
  MODIFY `id` int(250) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=50;

--
-- AUTO_INCREMENT for table `chat`
--
ALTER TABLE `chat`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1407;

--
-- AUTO_INCREMENT for table `friend_table`
--
ALTER TABLE `friend_table`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=233;

--
-- AUTO_INCREMENT for table `groupmembertable`
--
ALTER TABLE `groupmembertable`
  MODIFY `groupMemberId` int(250) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=212;

--
-- AUTO_INCREMENT for table `groupmessagetable`
--
ALTER TABLE `groupmessagetable`
  MODIFY `messageId` int(250) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=292;

--
-- AUTO_INCREMENT for table `grouptable`
--
ALTER TABLE `grouptable`
  MODIFY `groupId` int(250) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=108;

--
-- AUTO_INCREMENT for table `mutefriendstable`
--
ALTER TABLE `mutefriendstable`
  MODIFY `id` int(250) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=88;

--
-- AUTO_INCREMENT for table `requests`
--
ALTER TABLE `requests`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=180;

--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=202;

--
-- AUTO_INCREMENT for table `userstatus`
--
ALTER TABLE `userstatus`
  MODIFY `statusId` int(250) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=133;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `blockedtable`
--
ALTER TABLE `blockedtable`
  ADD CONSTRAINT `blockby` FOREIGN KEY (`blockedBy`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `userblocked` FOREIGN KEY (`userBlocked`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `chat`
--
ALTER TABLE `chat`
  ADD CONSTRAINT `user_user_email` FOREIGN KEY (`sender_email`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `user_with_email` FOREIGN KEY (`receiver_email`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `friend_table`
--
ALTER TABLE `friend_table`
  ADD CONSTRAINT `friend_email_with_user_email` FOREIGN KEY (`friend_email`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `user_name_with_user_email` FOREIGN KEY (`user_email`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `groupmembertable`
--
ALTER TABLE `groupmembertable`
  ADD CONSTRAINT `ab` FOREIGN KEY (`userEmail`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `av` FOREIGN KEY (`groupId`) REFERENCES `grouptable` (`groupId`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `groupmessagetable`
--
ALTER TABLE `groupmessagetable`
  ADD CONSTRAINT `x` FOREIGN KEY (`groupId`) REFERENCES `grouptable` (`groupId`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `y` FOREIGN KEY (`senderEmail`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `grouptable`
--
ALTER TABLE `grouptable`
  ADD CONSTRAINT `groupOwnerContraint` FOREIGN KEY (`groupOwnerEmail`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `mutefriendstable`
--
ALTER TABLE `mutefriendstable`
  ADD CONSTRAINT `abc` FOREIGN KEY (`userEmail`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `def` FOREIGN KEY (`friendEmail`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `requests`
--
ALTER TABLE `requests`
  ADD CONSTRAINT `req` FOREIGN KEY (`sender_email`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `reqs` FOREIGN KEY (`reciever_email`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `userstatus`
--
ALTER TABLE `userstatus`
  ADD CONSTRAINT `acv` FOREIGN KEY (`userEmail`) REFERENCES `user` (`email`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
