SQL Tutorial
Relational Database – Database management system used to create coordination b/w different
databases
What is a relational
database?
A relational database is a collection of information that organizes
data in predefined relationships where data is stored in one or
more tables (or "relations") of columns and rows, making it easy
to see and understand how different data structures relate to
each other. Relationships are a logical connection between
different tables, established on the basis of interaction among
these tables.
Relational Database Management System – MYSQL
What is a database
SQL code applicable to one RDB or one relational database might not be applicable to Other
RDB without slight modification
TABLES & KEYS
Primary Key – Row details
When forming a table – Primary Key is an attribute which uniquely decribes/identifies a Row in a
database.
Eg. – For Kate Primary Key – 1
Here EMAIL is the primary Key
Employee ID – Primary Key
Foreign Key – Branch id – is a primary key inside another Table
One table can have one or more Foreign Key(s)
Which Suppliers are supplying to which Branches
Here, Branch id & supplier name Together can Identify it
This defines How much an Employee has Sold to a Client
Eg. 101 Michael Scott has sold 267000 to 401or Lackawana Country
SQL BASICS
CREATING TABLES
DECIMAL (10,4) - Means 10 is the total number count, 4 numbers come after decimal
VARCHAR (100) – Means 100 characters can be the length
1st query Error - & Solution -
, after each intermediate line till the last line which lies before closed bracket ); - there no Comma (,)
to be kept