├── A simple database management system.ipynb ├── README.md └── v2.0 -using mongoDB ├── README.md ├── architecture.py └── model.py /A simple database management system.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## A SIMPLE DATABASE MANAGEMENT SYSTEM" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "1. MODE OF USERS:\n", 15 | " a. Admin\n", 16 | " b. Student\n", 17 | " \n", 18 | "2. FUNCTIONALITIES:\n", 19 | " a. Admin can:\n", 20 | " i. Store students/ sign_up\n", 21 | " ii. Update students info\n", 22 | " iii. Delete students records\n", 23 | " iv. Retrieve students Data\n", 24 | " v. View records (can see all students ID but cannot see other admins ID)\n", 25 | " b. Students can:\n", 26 | " i. Store their records/ sign_up\n", 27 | " ii. Update their info\n", 28 | " iii. Retrieve their Data\n", 29 | " iv. View records (can see their ID)\n", 30 | " \n", 31 | " \n", 32 | " 3. TRICK:\n", 33 | " \n", 34 | " a. You can quit/ exit the programme \n", 35 | " i. by entering 'stop' or nothing whenever you're prompted to input something\n", 36 | " ii. By entering 'No' at points where you're asked.\n", 37 | " \n", 38 | " b. You start the script by running 'architecure_tier_1()'\n", 39 | " \n", 40 | " c. After registering, you need to login again with your first name, last names and new ID before you can perform any actions" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": 4, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "class DSC_database:\n", 50 | " import pandas as pd\n", 51 | " stud_id, admin_id= ['ST_'+str(i) for i in list(range(1000, 20001))], ['AD_'+str(i) for i in list(range(100, 151))]\n", 52 | " database= pd.DataFrame(columns= ['Name', 'Email', 'Id', 'Mode']).set_index('Id')\n", 53 | "\n", 54 | " def __init__(self, first, last, email, i_d= None):\n", 55 | " self.first, self.last, self.email, self.i_d= first, last, email, None\n", 56 | " \n", 57 | " def Fullname(self):\n", 58 | " return self.first +' '+ self.last\n", 59 | " \n", 60 | " def Email(self):\n", 61 | " return self.email\n", 62 | " \n", 63 | " def sign_up(self, mode):\n", 64 | " import random\n", 65 | " if mode=='student':\n", 66 | " i_d= random.choice(self.stud_id)\n", 67 | " self.i_d= i_d\n", 68 | " self.stud_id.remove(i_d)\n", 69 | " self.database.loc[self.i_d]= {'Name': self.Fullname(), 'Email': self.Email(), 'Mode': mode}\n", 70 | " print(f'\\nWelcome {self.Fullname()}!!!\\nYour ID is {i_d}')\n", 71 | " return i_d\n", 72 | " elif mode=='admin':\n", 73 | " i_d= random.choice(self.admin_id)\n", 74 | " self.i_d= i_d\n", 75 | " self.admin_id.remove(i_d)\n", 76 | " self.database.loc[self.i_d]= {'Name': self.Fullname(), 'Email': self.Email(), 'Mode': mode}\n", 77 | " print(f'\\nWelcome!!!\\nYour ID is {i_d}')\n", 78 | " return i_d\n", 79 | " \n", 80 | " def retrive_data(self, i_d, mode):\n", 81 | " if mode== 'admin':\n", 82 | " if i_d in self.database.index:\n", 83 | " return self.database.loc[i_d]\n", 84 | " else:\n", 85 | " return '\\nUNREGISTERED ID'\n", 86 | " elif mode== 'student':\n", 87 | " if i_d in self.database.index and (i_d.startswith('a') == False):\n", 88 | " return self.database.loc[i_d]\n", 89 | " else:\n", 90 | " print('\\nUNREGISTERED ID')\n", 91 | " \n", 92 | " def delete_data(self, i_d):\n", 93 | " if i_d in self.database.index:\n", 94 | " self.database.drop(i_d, 0, inplace= True)\n", 95 | " print('\\nDONE!!!')\n", 96 | " else:\n", 97 | " print('\\nUNREGISTERED ID')\n", 98 | " \n", 99 | " def update_data(self, i_d, name, email):\n", 100 | " self.name, self.email= name, email\n", 101 | " if i_d in self.database.index:\n", 102 | " self.database.loc[i_d].Name= self.name\n", 103 | " self.database.loc[i_d].Email= self.email\n", 104 | " print(f'\\nIndividual with ID {i_d} updated')\n", 105 | " else:\n", 106 | " print('UNREGISTERED ID')\n", 107 | " \n", 108 | " def view_data(self, mode, i_d):\n", 109 | " import pandas as pd\n", 110 | " if mode=='admin' and i_d in self.database.index:\n", 111 | " return print(self.database)\n", 112 | " elif mode== 'student' and i_d in self.database.index:\n", 113 | " return print(self.database[self.database.Mode=='student'])\n", 114 | " else:\n", 115 | " print('Either unidentified mode or i_d, Try again!!')" 116 | ] 117 | }, 118 | { 119 | "cell_type": "markdown", 120 | "metadata": {}, 121 | "source": [ 122 | "Now we're done with the class, let's go on to build the architecture" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 2, 128 | "metadata": {}, 129 | "outputs": [], 130 | "source": [ 131 | "clearance= '''You've the clearance to:\n", 132 | "\\t1. Store students/ sign_up\n", 133 | "\\t2. Update students info\n", 134 | "\\t3. Retrieve students Data\n", 135 | "\\t4. Delete data (strictly for admins)\n", 136 | "\\t5. View data\n", 137 | "\n", 138 | "Reply with 1 -5 for your desired action'''\n", 139 | " \n", 140 | " \n", 141 | "def stop_tier_1():\n", 142 | " import sys\n", 143 | " ask= input('\\nDo you wish to continue: ')\n", 144 | " if ask.lower()=='yes':\n", 145 | " return architecure_tier_1()\n", 146 | " else:\n", 147 | " print('okay then, bye')\n", 148 | " return sys.exit()\n", 149 | " \n", 150 | "\n", 151 | "def stop_tier_2(item):\n", 152 | " if (item== '' or item.lower()== 'stop'):\n", 153 | " print('\\nOOps!!! Something has gone wrong')\n", 154 | " stop_tier_1()\n", 155 | " else:\n", 156 | " pass\n", 157 | "\n", 158 | " \n", 159 | "def architecure_tier_1():\n", 160 | " print('\\n\\n========================Welcome to MY DATABASE MANAGEMENT SYSTEM================================')\n", 161 | " mode= input('\\nAre you a Student or an Admin? \\n[Student/ Admin]: ')\n", 162 | " if mode.lower()== 'student' or 'admin':\n", 163 | " stop_tier_2(mode)\n", 164 | " architecture_tier_2(mode.lower(), 'database')\n", 165 | " else:\n", 166 | " print('\\nInvalid Mode')\n", 167 | " stop_tier_2()\n", 168 | " \n", 169 | " \n", 170 | "def architecture_tier_2(mode, database):\n", 171 | " import random\n", 172 | " global clearance\n", 173 | " first= input('\\nEnter your First Name: ').title()\n", 174 | " stop_tier_2(first)\n", 175 | " last= input('\\nEnter your Last Name: ').title()\n", 176 | " stop_tier_2(last)\n", 177 | " email= input('\\nEnter your Email: ')\n", 178 | " i_d= input('\\nEnter your ID (\"None\" if you\\'re not a member yet): ')\n", 179 | " stop_tier_2(i_d)\n", 180 | " user= DSC_database(first= first, last=last, email= email)\n", 181 | " \n", 182 | " if i_d.lower()== 'none':\n", 183 | " print('Looks like you need to sign up!\\n')\n", 184 | " confirm= input('Do you want to sign up? \\n[Yes/ No]:')\n", 185 | " if confirm.lower()== 'yes':\n", 186 | " i_d= user.sign_up(mode)\n", 187 | " ask= input('Do you wish to continue: ')\n", 188 | " if ask.lower()=='yes': return architecure_tier_1(); return 'okay then, bye'\n", 189 | " else:\n", 190 | " return 'okay then, bye'\n", 191 | "\n", 192 | " elif i_d in getattr(DSC_database, database).index and first+' '+last==\\\n", 193 | " getattr(DSC_database, database).loc[i_d].Name:\n", 194 | " print(f'\\nwelcome {user.Fullname()}\\n')\n", 195 | " print(clearance)\n", 196 | " request= int(input('Enter the action you desire to perform: \\n'))\n", 197 | " \n", 198 | " if request == 1:\n", 199 | " if mode.lower()== 'admin':\n", 200 | " mode= input('Enter the mode you wish to sign up: ')\n", 201 | " stop_tier_2(mode)\n", 202 | " first= input('\\nFirst Name: ').title()\n", 203 | " stop_tier_2(first)\n", 204 | " last= input('\\nLast Name: ').title()\n", 205 | " stop_tier_2(last)\n", 206 | " email= input('\\nEmail: ')\n", 207 | " user= DSC_database(first= first, last=last, email= email)\n", 208 | " i_d= user.sign_up(mode)\n", 209 | " else:\n", 210 | " i_d= user.sign_up('student')\n", 211 | " first= input('\\nFirst Name: ').title()\n", 212 | " stop_tier_2(first)\n", 213 | " last= input('\\nLast Name: ').title()\n", 214 | " stop_tier_2(last)\n", 215 | " email= input('\\nEmail: ')\n", 216 | " user= DSC_database(first= first, last=last, email= email)\n", 217 | " stop_tier_1()\n", 218 | " \n", 219 | " \n", 220 | " elif request == 2:\n", 221 | " name= input('Enter new name: ')\n", 222 | " email= input('Enter new Email: ')\n", 223 | " user.update_data(i_d, name, email)\n", 224 | " stop_tier_1()\n", 225 | " \n", 226 | " elif request == 3:\n", 227 | " i_d_needed= input('Enter the ID the person you wish to retrive their data')\n", 228 | " user.retrive_data(i_d_needed, mode)\n", 229 | " stop_tier_1()\n", 230 | " \n", 231 | " elif request == 4:\n", 232 | " if mode.lower()== 'admin':\n", 233 | " id_needed= input('Enter the ID you need to delete: ')\n", 234 | " user.delete_data(id_needed)\n", 235 | " else:\n", 236 | " print('Sorry, you\\'re not cleared for this action' )\n", 237 | " stop_tier_1()\n", 238 | " \n", 239 | " elif request == 5:\n", 240 | " user.view_data(mode, i_d)\n", 241 | " stop_tier_1()\n", 242 | " \n", 243 | " else:\n", 244 | " print('Invalid request')\n", 245 | " stop_tier_1()\n", 246 | " \n", 247 | " else:\n", 248 | " print('Invalid Log in database')\n", 249 | " stop_tier_1()" 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": 3, 255 | "metadata": { 256 | "scrolled": false 257 | }, 258 | "outputs": [ 259 | { 260 | "name": "stdout", 261 | "output_type": "stream", 262 | "text": [ 263 | "\n", 264 | "\n", 265 | "========================Welcome to MY DATABASE MANAGEMENT SYSTEM================================\n", 266 | "\n", 267 | "Are you a Student or an Admin? \n", 268 | "[Student/ Admin]: student\n", 269 | "\n", 270 | "Enter your First Name: Aisha\n", 271 | "\n", 272 | "Enter your Last Name: lawal\n", 273 | "\n", 274 | "Enter your Email: aishalawal@gmail.com\n", 275 | "\n", 276 | "Enter your ID (\"None\" if you're not a member yet): None\n", 277 | "Looks like you need to sign up!\n", 278 | "\n", 279 | "Do you want to sign up? \n", 280 | "[Yes/ No]:yes\n", 281 | "\n", 282 | "Welcome Aisha Lawal!!!\n", 283 | "Your ID is ST_14122\n", 284 | "Do you wish to continue: yes\n", 285 | "\n", 286 | "\n", 287 | "========================Welcome to MY DATABASE MANAGEMENT SYSTEM================================\n", 288 | "\n", 289 | "Are you a Student or an Admin? \n", 290 | "[Student/ Admin]: admin\n", 291 | "\n", 292 | "Enter your First Name: joe\n", 293 | "\n", 294 | "Enter your Last Name: biden\n", 295 | "\n", 296 | "Enter your Email: joebiden\n", 297 | "\n", 298 | "Enter your ID (\"None\" if you're not a member yet): None\n", 299 | "Looks like you need to sign up!\n", 300 | "\n", 301 | "Do you want to sign up? \n", 302 | "[Yes/ No]:yes\n", 303 | "\n", 304 | "Welcome!!!\n", 305 | "Your ID is AD_106\n", 306 | "Do you wish to continue: yes\n", 307 | "\n", 308 | "\n", 309 | "========================Welcome to MY DATABASE MANAGEMENT SYSTEM================================\n", 310 | "\n", 311 | "Are you a Student or an Admin? \n", 312 | "[Student/ Admin]: admin\n", 313 | "\n", 314 | "Enter your First Name: joe\n", 315 | "\n", 316 | "Enter your Last Name: biden\n", 317 | "\n", 318 | "Enter your Email: joebiden\n", 319 | "\n", 320 | "Enter your ID (\"None\" if you're not a member yet): AD_106\n", 321 | "\n", 322 | "welcome Joe Biden\n", 323 | "\n", 324 | "You've the clearance to:\n", 325 | "\t1. Store students/ sign_up\n", 326 | "\t2. Update students info\n", 327 | "\t3. Retrieve students Data\n", 328 | "\t4. Delete data (strictly for admins)\n", 329 | "\t5. View data\n", 330 | "\n", 331 | "Reply with 1 -5 for your desired action\n", 332 | "Enter the action you desire to perform: \n", 333 | "5\n", 334 | " Name Email Mode\n", 335 | "Id \n", 336 | "ST_14122 Aisha Lawal aishalawal@gmail.com student\n", 337 | "AD_106 Joe Biden joebiden admin\n", 338 | "\n", 339 | "Do you wish to continue: no\n", 340 | "okay then, bye\n" 341 | ] 342 | }, 343 | { 344 | "ename": "SystemExit", 345 | "evalue": "", 346 | "output_type": "error", 347 | "traceback": [ 348 | "An exception has occurred, use %tb to see the full traceback.\n", 349 | "\u001b[1;31mSystemExit\u001b[0m\n" 350 | ] 351 | }, 352 | { 353 | "name": "stderr", 354 | "output_type": "stream", 355 | "text": [ 356 | "C:\\Users\\USER\\anaconda3\\lib\\site-packages\\IPython\\core\\interactiveshell.py:3339: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.\n", 357 | " warn(\"To exit: use 'exit', 'quit', or Ctrl-D.\", stacklevel=1)\n" 358 | ] 359 | } 360 | ], 361 | "source": [ 362 | "architecure_tier_1()" 363 | ] 364 | }, 365 | { 366 | "cell_type": "code", 367 | "execution_count": null, 368 | "metadata": {}, 369 | "outputs": [], 370 | "source": [] 371 | } 372 | ], 373 | "metadata": { 374 | "kernelspec": { 375 | "display_name": "Python 3", 376 | "language": "python", 377 | "name": "python3" 378 | }, 379 | "language_info": { 380 | "codemirror_mode": { 381 | "name": "ipython", 382 | "version": 3 383 | }, 384 | "file_extension": ".py", 385 | "mimetype": "text/x-python", 386 | "name": "python", 387 | "nbconvert_exporter": "python", 388 | "pygments_lexer": "ipython3", 389 | "version": "3.7.6" 390 | } 391 | }, 392 | "nbformat": 4, 393 | "nbformat_minor": 4 394 | } 395 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 1. MODE OF USERS: 2 | a. Admin 3 | b. Student 4 | 5 | 2. FUNCTIONALITIES: 6 | a. Admin can: 7 | i. Store students/ sign_up 8 | ii. Update students info 9 | iii. Delete students records 10 | iv. Retrieve students Data 11 | v. View records (can see all students ID but cannot see other admins ID) 12 | b. Students can: 13 | i. Store their records/ sign_up 14 | ii. Update their info 15 | iii. Retrieve their Data 16 | iv. View records (can see their ID) 17 | 18 | 19 | 3. TRICK: 20 | 21 | a. You can quit/ exit the programme 22 | i. by entering 'stop' or nothing whenever you're prompted to input something 23 | ii. By entering 'No' at points where you're asked. 24 | 25 | b. You start the script by running 'architecure_tier_1()' 26 | 27 | c. After registering, you need to login again with your first name, last names and new ID before you can perform any actions 28 | -------------------------------------------------------------------------------- /v2.0 -using mongoDB/README.md: -------------------------------------------------------------------------------- 1 | 1. MODE OF USERS: 2 | a. Admin 3 | b. Student 4 | 5 | 2. FUNCTIONALITIES: 6 | a. Admin can: 7 | i. Store students/ sign_up 8 | ii. Update students info 9 | iii. Delete students records 10 | iv. Retrieve students Data 11 | v. View records (can see all students ID but cannot see other admins ID) 12 | b. Students can: 13 | i. Store their records/ sign_up 14 | ii. Update their info 15 | iii. Retrieve their Data 16 | iv. View records (can see their ID) 17 | 18 | 19 | 3. TRICK: 20 | 21 | a. You can quit/ exit the programme 22 | i. by entering 'stop' or nothing whenever you're prompted to input something 23 | ii. By entering 'No' at points where you're asked. 24 | 25 | b. You start the script by running 'architecure_tier_1()' 26 | 27 | c. After registering, you need to login again with your first name, last names and new ID before you can perform any actions 28 | -------------------------------------------------------------------------------- /v2.0 -using mongoDB/architecture.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuad28/A-simple-Database-Management-System/80f30544d2e1bfffd0640890582d0ec9c1e3b0e1/v2.0 -using mongoDB/architecture.py -------------------------------------------------------------------------------- /v2.0 -using mongoDB/model.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuad28/A-simple-Database-Management-System/80f30544d2e1bfffd0640890582d0ec9c1e3b0e1/v2.0 -using mongoDB/model.py --------------------------------------------------------------------------------