Database Management Notes_2
Database Management Notes_2
JOINS
CARTESIAN PRODUCT
A Cartesian product is the result of joining every row in one table with every row in another
table. This occurs when there is no WHERE clause to restrict rows.
Example:
SELECT eno,ename,title,salary,pno,pname,budget FROM emp,proj;
Example:
NATURAL-JOIN:
EQUI-JOIN:
INTERFACE OF PYTHON:
Install MySQL Driver
Python needs a MySQL driver to access the MySQL database.
In this tutorial we will use the driver "MySQL Connector".
We recommend that you use PIP to install "MySQL Connector".
PIP is most likely already installed in your Python environment.
Navigate your command line to the location of PIP, and type the following:
Create Connection
Start by creating a connection to the database.
Use the username and password from your MySQL database:
Creating a Database
To create a database in MySQL, use the "CREATE DATABASE" statement:
Creating a Table
To create a table in MySQL, use the "CREATE TABLE" statement.
Make sure you define the name of the database when you create the connection
To show tables
Primary Key
When creating a table, you should also create a column with a unique key for each record.
This can be done by defining a PRIMARY KEY.