Put files and deps in for online part 2b
This commit is contained in:
		
							parent
							
								
									df92a050dc
								
							
						
					
					
						commit
						45e9229d64
					
				
							
								
								
									
										150
									
								
								code/online-part-2b/MongoDB Aufgabe Daten.ipynb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								code/online-part-2b/MongoDB Aufgabe Daten.ipynb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,150 @@
 | 
			
		||||
{
 | 
			
		||||
 "cells": [
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "markdown",
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "source": [
 | 
			
		||||
    "## Zoo-Verwaltung in MongoDB\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "In diesem Beispiel soll die einfache Zoo-Verwaltung aus der Aufgabe zuvor in MongoDB umgesetzt werden. \n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "Installieren Sie dazu zunächst MongoDB auf Ihrem Rechner, hier finden Sie den Download und die Dokumentation zur Installation:\n",
 | 
			
		||||
    "https://www.mongodb.com/try/download/community\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "Um MongoDB in Python zu verwenden, benötigen Sie das Modul `pymongo`. Installieren Sie es mit dem folgenden Befehl:\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "    conda install conda-forge::pymongo\n",
 | 
			
		||||
    "\n"
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "code",
 | 
			
		||||
   "execution_count": null,
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "outputs": [],
 | 
			
		||||
   "source": [
 | 
			
		||||
    "# Client importieren\n",
 | 
			
		||||
    "from pymongo import MongoClient"
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "code",
 | 
			
		||||
   "execution_count": null,
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "outputs": [],
 | 
			
		||||
   "source": [
 | 
			
		||||
    "# TODO: Mit dieser Zelle können Sie testen, ob die Verbindung zur MongoDB-Datenbank funktioniert.\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "# Verbindungsaufbau zu einer MongoDB-Datenbank\n",
 | 
			
		||||
    "client = MongoClient('localhost', 27017)\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "# Zoo-Datenbank erstellen\n",
 | 
			
		||||
    "db = client['zoo']\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "# Beispiel-Dokument in Collection 'animals' erstellen\n",
 | 
			
		||||
    "db.animals.insert_one({'name': 'Ella', 'species': 'elephant'})\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "# Alle Dokumente in Collection 'animals' ausgeben\n",
 | 
			
		||||
    "for animal in db.animals.find():\n",
 | 
			
		||||
    "    print(animal)"
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "markdown",
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "source": [
 | 
			
		||||
    "### Teilaufgabe 1 (4 Punkte): \n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "Fügen Sie im folgenden Dokumente ein, die die selben Informationen enthalten wie in der Aufgabe zuvor. Dabei sollen drei Tiere mit zwei Tierpfegern erstellt werden. Ein Tierpfleger versorgt mehrere Tiere, jedes Tier ist genau einem Tierpfleger zugeordnet. Ob Sie die Daten dabei normalisieren oder nicht, bleibt Ihnen überlassen."
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "code",
 | 
			
		||||
   "execution_count": null,
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "outputs": [],
 | 
			
		||||
   "source": [
 | 
			
		||||
    "# TODO: Einfügen von Daten:\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "# db.animals.insert_one(...)\n",
 | 
			
		||||
    "# db.animals.insert_many(...)\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "# Falls Sie mehrere Collections nutzen...\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "# db.zookeeper.insert_one(...)"
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "markdown",
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "source": [
 | 
			
		||||
    "### Teilaufgabe 2 (3 Punkte): \n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "Erstellen Sie jetzt noch eine Funktion, die einen Überblick über alle Tiere im Zoo gibt, die Ausgabe soll dabei dem Beispiel ähneln."
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "code",
 | 
			
		||||
   "execution_count": null,
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "outputs": [],
 | 
			
		||||
   "source": [
 | 
			
		||||
    "# TODO: Ausgabe aller Daten\n",
 | 
			
		||||
    "def zoo_overview():\n",
 | 
			
		||||
    "    pass\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "# Beispielausgabe:\n",
 | 
			
		||||
    "#    \n",
 | 
			
		||||
    "# ----------------------------------------\n",
 | 
			
		||||
    "# | Babar      | Elephant   | John Doe   |\n",
 | 
			
		||||
    "# | Dumbo      | Elephant   | John Doe   |\n",
 | 
			
		||||
    "# | Hathi      | Elephant   | John Doe   |\n",
 | 
			
		||||
    "# | Melman     | Giraffe    | Jane Doe   |\n",
 | 
			
		||||
    "# | Gloria     | Giraffe    | Jane Doe   |\n",
 | 
			
		||||
    "# ----------------------------------------\n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "# Testaufruf\n",
 | 
			
		||||
    "zoo_overview()"
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "markdown",
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "source": [
 | 
			
		||||
    "### Teilaufgabe 3 (3 Punkte): \n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "Begründen Sie, warum Sie die Struktur der Datenbank so gewählt haben, wie Sie es getan haben. \n",
 | 
			
		||||
    "\n",
 | 
			
		||||
    "Welche Vor- und Nachteile hat Ihre Lösung (für volle Punktzahl sollten Sie mindestens 2 Vor- und 2 Nachteile nennen)?\n"
 | 
			
		||||
   ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "markdown",
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "source": [
 | 
			
		||||
    "Antwort: "
 | 
			
		||||
   ]
 | 
			
		||||
  }
 | 
			
		||||
 ],
 | 
			
		||||
 "metadata": {
 | 
			
		||||
  "kernelspec": {
 | 
			
		||||
   "display_name": "base",
 | 
			
		||||
   "language": "python",
 | 
			
		||||
   "name": "python3"
 | 
			
		||||
  },
 | 
			
		||||
  "language_info": {
 | 
			
		||||
   "codemirror_mode": {
 | 
			
		||||
    "name": "ipython",
 | 
			
		||||
    "version": 3
 | 
			
		||||
   },
 | 
			
		||||
   "file_extension": ".py",
 | 
			
		||||
   "mimetype": "text/x-python",
 | 
			
		||||
   "name": "python",
 | 
			
		||||
   "nbconvert_exporter": "python",
 | 
			
		||||
   "pygments_lexer": "ipython3",
 | 
			
		||||
   "version": "3.11.0"
 | 
			
		||||
  }
 | 
			
		||||
 },
 | 
			
		||||
 "nbformat": 4,
 | 
			
		||||
 "nbformat_minor": 2
 | 
			
		||||
}
 | 
			
		||||
@ -7,4 +7,5 @@ dependencies = [
 | 
			
		||||
    "matplotlib>=3.10.3",
 | 
			
		||||
    "numpy>=2.2.5",
 | 
			
		||||
    "pandas>=2.2.3",
 | 
			
		||||
    "pymongo>=4.12.1",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										40
									
								
								code/uv.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										40
									
								
								code/uv.lock
									
									
									
										generated
									
									
									
								
							@ -51,6 +51,7 @@ dependencies = [
 | 
			
		||||
    { name = "matplotlib" },
 | 
			
		||||
    { name = "numpy" },
 | 
			
		||||
    { name = "pandas" },
 | 
			
		||||
    { name = "pymongo" },
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[package.metadata]
 | 
			
		||||
@ -59,6 +60,7 @@ requires-dist = [
 | 
			
		||||
    { name = "matplotlib", specifier = ">=3.10.3" },
 | 
			
		||||
    { name = "numpy", specifier = ">=2.2.5" },
 | 
			
		||||
    { name = "pandas", specifier = ">=2.2.3" },
 | 
			
		||||
    { name = "pymongo", specifier = ">=4.12.1" },
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
@ -144,6 +146,15 @@ wheels = [
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/4e/8c/f3147f5c4b73e7550fe5f9352eaa956ae838d5c51eb58e7a25b9f3e2643b/decorator-5.2.1-py3-none-any.whl", hash = "sha256:d316bb415a2d9e2d2b3abcc4084c6502fc09240e292cd76a76afc106a1c8e04a", size = 9190 },
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "dnspython"
 | 
			
		||||
version = "2.7.0"
 | 
			
		||||
source = { registry = "https://pypi.org/simple" }
 | 
			
		||||
sdist = { url = "https://files.pythonhosted.org/packages/b5/4a/263763cb2ba3816dd94b08ad3a33d5fdae34ecb856678773cc40a3605829/dnspython-2.7.0.tar.gz", hash = "sha256:ce9c432eda0dc91cf618a5cedf1a4e142651196bbcd2c80e89ed5a907e5cfaf1", size = 345197 }
 | 
			
		||||
wheels = [
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/68/1b/e0a87d256e40e8c888847551b20a017a6b98139178505dc7ffb96f04e954/dnspython-2.7.0-py3-none-any.whl", hash = "sha256:b4c34b7d10b51bcc3a5071e7b8dee77939f1e878477eeecc965e9835f63c6c86", size = 313632 },
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "executing"
 | 
			
		||||
version = "2.2.0"
 | 
			
		||||
@ -544,6 +555,35 @@ wheels = [
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293 },
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "pymongo"
 | 
			
		||||
version = "4.12.1"
 | 
			
		||||
source = { registry = "https://pypi.org/simple" }
 | 
			
		||||
dependencies = [
 | 
			
		||||
    { name = "dnspython" },
 | 
			
		||||
]
 | 
			
		||||
sdist = { url = "https://files.pythonhosted.org/packages/85/27/3634b2e8d88ad210ee6edac69259c698aefed4a79f0f7356cd625d5c423c/pymongo-4.12.1.tar.gz", hash = "sha256:8921bac7f98cccb593d76c4d8eaa1447e7d537ba9a2a202973e92372a05bd1eb", size = 2165515 }
 | 
			
		||||
wheels = [
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/0c/4d/e6654f3ec6819980cbad77795ccf2275cd65d6df41375a22cdbbccef8416/pymongo-4.12.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:90de2b060d69c22658ada162a5380a0f88cb8c0149023241b9e379732bd36152", size = 965051 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/54/95/627a047c32789544a938abfd9311c914e622cb036ad16866e7e1b9b80239/pymongo-4.12.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:edf4e05331ac875d3b27b4654b74d81e44607af4aa7d6bcd4a31801ca164e6fd", size = 964732 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/8f/6d/7a604e3ab5399f8fe1ca88abdbf7e54ceb6cf03e64f68b2ed192d9a5eaf5/pymongo-4.12.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fa7a817c9afb7b8775d98c469ddb3fe9c17daf53225394c1a74893cf45d3ade9", size = 1953037 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/d5/d5/269388e7b0d02d35f55440baf1e0120320b6db1b555eaed7117d04b35402/pymongo-4.12.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f9d142ca531694e9324b3c9ba86c0e905c5f857599c4018a386c4dc02ca490fa", size = 2030467 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/4b/d0/04a6b48d6ca3fc2ff156185a3580799a748cf713239d6181e91234a663d3/pymongo-4.12.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d5d4c0461f5cd84d9fe87d5a84b1bc16371c4dd64d56dcfe5e69b15c0545a5ac", size = 1994139 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/ad/65/0567052d52c0ac8aaa4baa700b39cdd1cf2481d2e59bd9817a3daf169ca0/pymongo-4.12.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:43afd2f39182731ac9fb81bbc9439d539e4bd2eda72cdee829d2fa906a1c4d37", size = 1954947 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/c5/5b/db25747b288218dbdd97e9aeff6a3bfa3f872efb4ed06fa8bec67b2a121e/pymongo-4.12.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:827ac668c003da7b175b8e5f521850e2c182b4638a3dec96d97f0866d5508a1e", size = 1904374 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/fc/1e/6d0eb040c02ae655fafd63bd737e96d7e832eecfd0bd37074d0066f94a78/pymongo-4.12.1-cp313-cp313-win32.whl", hash = "sha256:7c2269b37f034124a245eaeb34ce031cee64610437bd597d4a883304babda3cd", size = 925869 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/59/b9/459da646d9750529f04e7e686f0cd8dd40174138826574885da334c01b16/pymongo-4.12.1-cp313-cp313-win_amd64.whl", hash = "sha256:3b28ecd1305b89089be14f137ffbdf98a3b9f5c8dbbb2be4dec084f2813fbd5f", size = 948411 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/c9/c3/75be116159f210811656ec615b2248f63f1bc9dd1ce641e18db2552160f0/pymongo-4.12.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:f27b22a8215caff68bdf46b5b61ccd843a68334f2aa4658e8d5ecb5d3fbebb3b", size = 1021562 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/cd/d1/2e8e368cad1c126a68365a6f53feaade58f9a16bd5f7a69f218af119b0e9/pymongo-4.12.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:5e9d23a3c290cf7409515466a7f11069b70e38ea2b786bbd7437bdc766c9e176", size = 1021553 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/17/6e/a6460bc1e3d3f5f46cc151417427b2687a6f87972fd68a33961a37c114df/pymongo-4.12.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:efeb430f7ca8649a6544a50caefead343d1fd096d04b6b6a002c6ce81148a85c", size = 2281736 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/1a/e2/9e1d6f1a492bb02116074baa832716805a0552d757c176e7c5f40867ca80/pymongo-4.12.1-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a34e4a08bbcff56fdee86846afbc9ce751de95706ca189463e01bf5de3dd9927", size = 2368964 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/fa/df/88143016eca77e79e38cf072476c70dd360962934430447dabc9c6bef6df/pymongo-4.12.1-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b063344e0282537f05dbb11147591cbf58fc09211e24fc374749e343f880910a", size = 2327834 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/3c/0d/df2998959b52cd5682b11e6eee1b0e0c104c07abd99c9cde5a871bb299fd/pymongo-4.12.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c3f7941e01b3e5d4bfb3b4711425e809df8c471b92d1da8d6fab92c7e334a4cb", size = 2279126 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/fb/3e/102636f5aaf97ccfa2a156c253a89f234856a0cd252fa602d4bf077ba3c0/pymongo-4.12.1-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b41235014031739f32be37ff13992f51091dae9a5189d3bcc22a5bf81fd90dae", size = 2218136 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/44/c9/1b534c9d8d91d9d98310f2d955c5331fb522bd2a0105bd1fc31771d53758/pymongo-4.12.1-cp313-cp313t-win32.whl", hash = "sha256:9a1f07fe83a8a34651257179bd38d0f87bd9d90577fcca23364145c5e8ba1bc0", size = 974747 },
 | 
			
		||||
    { url = "https://files.pythonhosted.org/packages/08/e2/7d3a30ac905c99ea93729e03d2bb3d16fec26a789e98407d61cb368ab4bb/pymongo-4.12.1-cp313-cp313t-win_amd64.whl", hash = "sha256:46d86cf91ee9609d0713242a1d99fa9e9c60b4315e1a067b9a9e769bedae629d", size = 1003332 },
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "pyparsing"
 | 
			
		||||
version = "3.2.3"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user