SlideShare a Scribd company logo
1 of 29
Download to read offline
Database Tables
Design, Constraints and
Indexes
Spotle.ai Study Material
Spotle.ai/Learn
Spotle.ai Study Material
Spotle.ai/Learn
A relational database stores data in
the form of tables. (Like excel grids
or tables in Word).
Employee_Name Employee_Id Designation
Seema Rathod 123344 Manager
G Balakrishnan 144555 Software Engineer
Asif Iqbal 134455 Senior Architect
Tina Das 157772 Business Analyst
2
Table: Employee
Spotle.ai Study Material
Spotle.ai/Learn
See the employee table. Each
column stores a particular attribute.
Each row stores data of one
employee.
Employee_Name Employee_Id Designation
Seema Rathod 123344 Manager
G Balakrishnan 144555 Software Engineer
Asif Iqbal 134455 Senior Architect
Tina Das 157772 Business Analyst
3
Table: Employee
Spotle.ai Study Material
Spotle.ai/Learn
4
Using tables it is
easy to model or
store relationships
between entities. For
example, Spotle can
have a user table, a
course table and a
user x course table
that maps users to
courses they are
enrolled in.
User_id
User_name
Course_id
Course_name
User_id
Course_id
User Course
User_x_course
Spotle.ai Study Material
Spotle.ai/Learn
How Do
You Arrive
At The
Tables You
Need?
5
Spotle.ai Study Material
Spotle.ai/Learn
Step 1:
Understand
the Problem
Statement
6
Spotle.ai Study Material
Spotle.ai/Learn
7
Problem Statement:
I want to develop a
student application
which will have data
of students, their
courses and marks.
Spotle.ai Study Material
Spotle.ai/Learn
8
Step 2:
Derive the major
entities whose
information you will
need to store. The
question you ask is:
What information do I
need?
Spotle.ai Study Material
Spotle.ai/Learn
9
Step 2:
You can do this by
underlining the nouns
in your problem
statement. Let’s
revisit our problem
statement:
Spotle.ai Study Material
Spotle.ai/Learn
10
Problem Statement:
I want to develop a
student application
which will have data
of students, their
courses and marks.
Spotle.ai Study Material
Spotle.ai/Learn
11
Step 2:
So you have got 3
entities: student, marks
of students, courses
subscribed by students.
These become your
tables. You may need
some more (or less)
tables which we
discover in next steps.
Spotle.ai Study Material
Spotle.ai/Learn
12
Step 3: Turn entity
attributes into
columns:
Determine the
information you will
store about each
entity. These attributes
become table
columns.
Spotle.ai Study Material
Spotle.ai/Learn
13
Student Attributes:
Name
Roll_Number
Phone_number
Email_address
Challenge: Think
and share what
other attributes you
will want to store
about a student?
Spotle.ai Study Material
Spotle.ai/Learn
14
Course Attributes:
Course Name
Course Description
Course Instructor Name
Course Subject
Course Difficulty Level
Image
Challenge: Think and share what other
attributes you will want to store about a
course?
Spotle.ai Study Material
Spotle.ai/Learn
15
Step 4:
Determine primary keys
for each table. A primary
key is the attribute that
uniquely identifies each
record in a table.
Spotle.ai Study Material
Spotle.ai/Learn
A student has a unique roll_no. We
can designate roll_no as the
primary key.
16
Table: Student
Student_Name Roll_No Email_Id
Seema Rathod 123344 Manager
G Balakrishnan 144555 Software Engineer
Asif Iqbal 134455 Senior Architect
Tina Das 157772 Business Analyst
Spotle.ai Study Material
Spotle.ai/Learn
In the list of course attributes, we do not have
a unique identifier. (Course names can be
same for example 2 courses on Biology with
different difficulty levels). So we give course a
unique id and add it to the table.
17
Table: Course
Course_id Course_Name Course_desc Course_level
1 Certificate In Biology Basic Biology Beginner
2 Certificate In Biology Advanced biology Advanced
3 English Level 1 Basic English Beginner
4 Mathematics
Refresher
Advanced Maths Advanced
Spotle.ai Study Material
Spotle.ai/Learn
18
Step 5: Model
relationships
between tables
You may need to derive
additional tables to store
the relationships. In our
example, we derived a
student_x_course table to
store which student has
taken what course.
Student Course
Roll_no
Course_id
Student_x_course
Spotle.ai Study Material
Spotle.ai/Learn
19
Step 6: Normalise
Tables
Normalisation is the
database technique of
reducing redundancy and
dependency in data by
systematically splitting
tables.
Spotle.ai Study Material
Spotle.ai/Learn
Suppose a course has multiple instructors. How will
you store the information? You can add another row for
the course but then the primary key is repeated
causing design to break. Also all course details are
repeated unnecessarily.
20
Table: Course
Course_id Course_Name Course_desc Course_level Instructor Name
1 Certificate In
Biology
Basic Biology Beginner Md Rafi
1 Certificate In
Biology
Basic Biology Beginner Kishor Ganguly
2 Certificate In
Biology
Advanced
biology
Advanced Asif Iqbal
3 English Level 1 Basic English Beginner Smriti K
4 Mathematics
Refresher
Advanced
Maths
Advanced Sam Joseph
Spotle.ai Study Material
Spotle.ai/Learn
21
Table: Course
Course_id Course_Name Course_desc Course_level
1 Certificate In
Biology
Basic Biology Beginner
2 Certificate In
Biology
Advanced
biology
Advanced
3 English Level 1 Basic English Beginner
4 Mathematics
Refresher
Advanced
Maths
Advanced
Instructor_Id Instructor
_Name
1 Md Rafi
2 K Ganguly
3 Asif Iqbal
4 Smriti K
5 Sam Joseph
Course_x_instructor_
id
Course_id Instructor_id
1 1 1
2 1 2
3 2 3
4 3 4
5 4 5
Normalised design where
the larger course table is
split into a course table
and instructor table. Their
relationship is stored in a
third table: the
course_x_instructor table.
Table: Course_x_Instructor
Table: Instructor
Spotle.ai Study Material
Spotle.ai/Learn
22
Constraints are used to
ensure integrity of the
data in the database.
Spotle.ai Study Material
Spotle.ai/Learn
22
Table Constraints
Spotle.ai Study Material
Spotle.ai/Learn 23
Constraints are used to ensure
integrity of the data in the
database. They are imposed on
table columns to enforce certain
rules on the data ensuring
integrity, accuracy and reliability.
Constraints
Spotle.ai Study Material
Spotle.ai/Learn 24
1. Primary Key
2. Unique
3. Not Null
4. Foreign Key
5. Default Constraint
6. Check Constraint
7. Index
Types Of Constraints
Spotle.ai Study Material
Spotle.ai/Learn
25
Primary Key:
A primary key is a table column (or
combination of columns) used to
uniquely identify every record in the
table. A primary key value has to be
unique and not-null for every row in
the database. For example, the
roll_no in the student table.
Spotle.ai Study Material
Spotle.ai/Learn
26
Foreign Key:
A foreign key is a column or group
of columns in a table links records
between data in two tables. It
creates a cross-reference between
tables by referencing the
primary key of another table.
Spotle.ai Study Material
Spotle.ai/Learn
27
Table: Course
Course_id Course_Name Course_desc Course_level
1 Certificate In
Biology
Basic Biology Beginner
2 Certificate In
Biology
Advanced
biology
Advanced
3 English Level 1 Basic English Beginner
4 Mathematics
Refresher
Advanced
Maths
Advanced
Instructor_Id Instructor
_Name
1 Md Rafi
2 K Ganguly
3 Asif Iqbal
4 Smriti K
5 Sam Joseph
Course_x_instructor_
id
Course_id Instructor_id
1 1 1
2 1 2
3 2 3
4 3 4
5 4 5
The course_id in the
course_x_instructor table is a
foreign key referencing the
course_id in Course table. The
instructor_id in the
course_x_instructor table is a
foreign key references the
instructor_id in the Instructor
table.
Table: Instructor
Table: Course_x_Instructor
Spotle.ai Study Material
Spotle.ai/Learn 28
1. Unique – enforces that the column value is
unique for every row.
2. Not Null – enforces that the column value is
not null for any row.
3. Default Constraint – prescribes a default
value of the column which is used to
populate any new row. The default value
can be over-written.
4. Check Constraint – designates a pre-
condition that the column data must adhere
to.
More Constraints Explained
Spotle.ai Study Material
Spotle.ai/Learn 29
Indexes are used to retrieve data from the database fast. An index is a pointer to
data in a table that the database search engine uses to speed up select queries.
Indexes are created on columns which are more likely to be used in search
queries or after the where condition in the select statement. For example if you are
likely to look up the Course table based on course_name you will create an index
on name.
Databases automatically create indexes on columns corresponding to primary
keys and unique constraints. Any custom index you need has to be create with the
Create Index command as shown:
Create Index Course_Name on Course;
Note: Indexes speed up select queries but slow down insert and update
statements as any insert or update will need an update of the corresponding index
too.
Indexes

More Related Content

Similar to Table - Design, Constraints and Indexes

Keller bis-245-week-5-lab-er-diagram-and-er-matrix-new
Keller bis-245-week-5-lab-er-diagram-and-er-matrix-newKeller bis-245-week-5-lab-er-diagram-and-er-matrix-new
Keller bis-245-week-5-lab-er-diagram-and-er-matrix-newshyaminfo102
 
Data Clustering in Education for Students
Data Clustering in Education for StudentsData Clustering in Education for Students
Data Clustering in Education for StudentsIRJET Journal
 
IT6701-Information Management Unit 1
IT6701-Information Management Unit 1IT6701-Information Management Unit 1
IT6701-Information Management Unit 1SIMONTHOMAS S
 
[Pick the date] Class Instructor’s NameWhat Is Autism.docx
[Pick the date]  Class  Instructor’s NameWhat Is Autism.docx[Pick the date]  Class  Instructor’s NameWhat Is Autism.docx
[Pick the date] Class Instructor’s NameWhat Is Autism.docxdanielfoster65629
 
Advanced database
Advanced databaseAdvanced database
Advanced databasenasir1024
 
Module03
Module03Module03
Module03susir
 
Course-Plan-Object Oriented Concept (18CS45)1.pdf
Course-Plan-Object Oriented Concept (18CS45)1.pdfCourse-Plan-Object Oriented Concept (18CS45)1.pdf
Course-Plan-Object Oriented Concept (18CS45)1.pdfabhijit.tec
 
Database Management System
Database Management SystemDatabase Management System
Database Management SystemMavict De Leon
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFBiplap Bhattarai
 
Project Template - Artificial Intelligence and Data Science
Project Template - Artificial Intelligence and Data ScienceProject Template - Artificial Intelligence and Data Science
Project Template - Artificial Intelligence and Data ScienceLeaving A Legacy
 
Session #4 b content providers
Session #4 b  content providersSession #4 b  content providers
Session #4 b content providersVitali Pekelis
 
Mba2216 week 11 data analysis part 01
Mba2216 week 11 data analysis part 01Mba2216 week 11 data analysis part 01
Mba2216 week 11 data analysis part 01Stephen Ong
 
2011 tf r science syllabus md 2nd year sped only.final
2011 tf r science syllabus md 2nd year sped only.final2011 tf r science syllabus md 2nd year sped only.final
2011 tf r science syllabus md 2nd year sped only.finalSidwell Friends School
 
Chapter 6Structuring the Environment
Chapter 6Structuring the EnvironmentChapter 6Structuring the Environment
Chapter 6Structuring the EnvironmentJinElias52
 

Similar to Table - Design, Constraints and Indexes (20)

Keller bis-245-week-5-lab-er-diagram-and-er-matrix-new
Keller bis-245-week-5-lab-er-diagram-and-er-matrix-newKeller bis-245-week-5-lab-er-diagram-and-er-matrix-new
Keller bis-245-week-5-lab-er-diagram-and-er-matrix-new
 
Advanced_SQL_Presentation_Template.pptx
Advanced_SQL_Presentation_Template.pptxAdvanced_SQL_Presentation_Template.pptx
Advanced_SQL_Presentation_Template.pptx
 
Data Clustering in Education for Students
Data Clustering in Education for StudentsData Clustering in Education for Students
Data Clustering in Education for Students
 
IT6701-Information Management Unit 1
IT6701-Information Management Unit 1IT6701-Information Management Unit 1
IT6701-Information Management Unit 1
 
[Pick the date] Class Instructor’s NameWhat Is Autism.docx
[Pick the date]  Class  Instructor’s NameWhat Is Autism.docx[Pick the date]  Class  Instructor’s NameWhat Is Autism.docx
[Pick the date] Class Instructor’s NameWhat Is Autism.docx
 
Teknik-Tekniknya
Teknik-TekniknyaTeknik-Tekniknya
Teknik-Tekniknya
 
Excel2007 Power Point Slides
Excel2007 Power Point SlidesExcel2007 Power Point Slides
Excel2007 Power Point Slides
 
Advanced database
Advanced databaseAdvanced database
Advanced database
 
Database_Introduction.pdf
Database_Introduction.pdfDatabase_Introduction.pdf
Database_Introduction.pdf
 
Module03
Module03Module03
Module03
 
Mba 758 database management system
Mba 758 database management systemMba 758 database management system
Mba 758 database management system
 
Course-Plan-Object Oriented Concept (18CS45)1.pdf
Course-Plan-Object Oriented Concept (18CS45)1.pdfCourse-Plan-Object Oriented Concept (18CS45)1.pdf
Course-Plan-Object Oriented Concept (18CS45)1.pdf
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
 
Formulating a search strategy
Formulating a search strategyFormulating a search strategy
Formulating a search strategy
 
Project Template - Artificial Intelligence and Data Science
Project Template - Artificial Intelligence and Data ScienceProject Template - Artificial Intelligence and Data Science
Project Template - Artificial Intelligence and Data Science
 
Session #4 b content providers
Session #4 b  content providersSession #4 b  content providers
Session #4 b content providers
 
Mba2216 week 11 data analysis part 01
Mba2216 week 11 data analysis part 01Mba2216 week 11 data analysis part 01
Mba2216 week 11 data analysis part 01
 
2011 tf r science syllabus md 2nd year sped only.final
2011 tf r science syllabus md 2nd year sped only.final2011 tf r science syllabus md 2nd year sped only.final
2011 tf r science syllabus md 2nd year sped only.final
 
Chapter 6Structuring the Environment
Chapter 6Structuring the EnvironmentChapter 6Structuring the Environment
Chapter 6Structuring the Environment
 

More from Spotle.ai

Spotle AI-thon - AI For Good Business Plan Showcase - Team IIM Indore - AI Ro...
Spotle AI-thon - AI For Good Business Plan Showcase - Team IIM Indore - AI Ro...Spotle AI-thon - AI For Good Business Plan Showcase - Team IIM Indore - AI Ro...
Spotle AI-thon - AI For Good Business Plan Showcase - Team IIM Indore - AI Ro...Spotle.ai
 
Spotle AI-thon - AI For Good Business Plan Showcase - Cummins College
Spotle AI-thon - AI For Good Business Plan Showcase - Cummins CollegeSpotle AI-thon - AI For Good Business Plan Showcase - Cummins College
Spotle AI-thon - AI For Good Business Plan Showcase - Cummins CollegeSpotle.ai
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Elit...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Elit...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Elit...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Elit...Spotle.ai
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India- Ankur chat...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India- Ankur chat...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India- Ankur chat...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India- Ankur chat...Spotle.ai
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team La c...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team La c...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team La c...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team La c...Spotle.ai
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Temp...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Temp...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Temp...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Temp...Spotle.ai
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Zer...
 Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Zer... Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Zer...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Zer...Spotle.ai
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Shivam Gi...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Shivam Gi...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Shivam Gi...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Shivam Gi...Spotle.ai
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Cyber Pun...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Cyber Pun...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Cyber Pun...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Cyber Pun...Spotle.ai
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Tech Owls...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Tech Owls...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Tech Owls...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Tech Owls...Spotle.ai
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Jar...
 Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Jar... Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Jar...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Jar...Spotle.ai
 
Artificial intelligence in fintech
Artificial intelligence in fintechArtificial intelligence in fintech
Artificial intelligence in fintechSpotle.ai
 
Semi-supervised Machine Learning
Semi-supervised Machine LearningSemi-supervised Machine Learning
Semi-supervised Machine LearningSpotle.ai
 
Basics of Reinforcement Learning
Basics of Reinforcement LearningBasics of Reinforcement Learning
Basics of Reinforcement LearningSpotle.ai
 
Tableau And Data Visualization - Get Started
Tableau And Data Visualization - Get StartedTableau And Data Visualization - Get Started
Tableau And Data Visualization - Get StartedSpotle.ai
 
Artificial Intelligence in FinTech
Artificial Intelligence in FinTechArtificial Intelligence in FinTech
Artificial Intelligence in FinTechSpotle.ai
 
Supervised and Unsupervised Machine Learning
Supervised and Unsupervised Machine LearningSupervised and Unsupervised Machine Learning
Supervised and Unsupervised Machine LearningSpotle.ai
 
Growing-up With AI
Growing-up With AIGrowing-up With AI
Growing-up With AISpotle.ai
 
AI And Cyber-security Threats
AI And Cyber-security ThreatsAI And Cyber-security Threats
AI And Cyber-security ThreatsSpotle.ai
 
Robotic Process Automation With Blue Prism
Robotic Process Automation With Blue PrismRobotic Process Automation With Blue Prism
Robotic Process Automation With Blue PrismSpotle.ai
 

More from Spotle.ai (20)

Spotle AI-thon - AI For Good Business Plan Showcase - Team IIM Indore - AI Ro...
Spotle AI-thon - AI For Good Business Plan Showcase - Team IIM Indore - AI Ro...Spotle AI-thon - AI For Good Business Plan Showcase - Team IIM Indore - AI Ro...
Spotle AI-thon - AI For Good Business Plan Showcase - Team IIM Indore - AI Ro...
 
Spotle AI-thon - AI For Good Business Plan Showcase - Cummins College
Spotle AI-thon - AI For Good Business Plan Showcase - Cummins CollegeSpotle AI-thon - AI For Good Business Plan Showcase - Cummins College
Spotle AI-thon - AI For Good Business Plan Showcase - Cummins College
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Elit...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Elit...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Elit...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Elit...
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India- Ankur chat...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India- Ankur chat...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India- Ankur chat...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India- Ankur chat...
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team La c...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team La c...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team La c...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team La c...
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Temp...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Temp...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Temp...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Temp...
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Zer...
 Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Zer... Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Zer...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Zer...
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Shivam Gi...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Shivam Gi...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Shivam Gi...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Shivam Gi...
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Cyber Pun...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Cyber Pun...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Cyber Pun...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Cyber Pun...
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Tech Owls...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Tech Owls...Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Tech Owls...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Tech Owls...
 
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Jar...
 Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Jar... Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Jar...
Spotle AI-thon Top 10 Showcase - Analysing Mental Health Of India - Team Jar...
 
Artificial intelligence in fintech
Artificial intelligence in fintechArtificial intelligence in fintech
Artificial intelligence in fintech
 
Semi-supervised Machine Learning
Semi-supervised Machine LearningSemi-supervised Machine Learning
Semi-supervised Machine Learning
 
Basics of Reinforcement Learning
Basics of Reinforcement LearningBasics of Reinforcement Learning
Basics of Reinforcement Learning
 
Tableau And Data Visualization - Get Started
Tableau And Data Visualization - Get StartedTableau And Data Visualization - Get Started
Tableau And Data Visualization - Get Started
 
Artificial Intelligence in FinTech
Artificial Intelligence in FinTechArtificial Intelligence in FinTech
Artificial Intelligence in FinTech
 
Supervised and Unsupervised Machine Learning
Supervised and Unsupervised Machine LearningSupervised and Unsupervised Machine Learning
Supervised and Unsupervised Machine Learning
 
Growing-up With AI
Growing-up With AIGrowing-up With AI
Growing-up With AI
 
AI And Cyber-security Threats
AI And Cyber-security ThreatsAI And Cyber-security Threats
AI And Cyber-security Threats
 
Robotic Process Automation With Blue Prism
Robotic Process Automation With Blue PrismRobotic Process Automation With Blue Prism
Robotic Process Automation With Blue Prism
 

Recently uploaded

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyAnusha Are
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 

Recently uploaded (20)

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

Table - Design, Constraints and Indexes

  • 1. Database Tables Design, Constraints and Indexes Spotle.ai Study Material Spotle.ai/Learn
  • 2. Spotle.ai Study Material Spotle.ai/Learn A relational database stores data in the form of tables. (Like excel grids or tables in Word). Employee_Name Employee_Id Designation Seema Rathod 123344 Manager G Balakrishnan 144555 Software Engineer Asif Iqbal 134455 Senior Architect Tina Das 157772 Business Analyst 2 Table: Employee
  • 3. Spotle.ai Study Material Spotle.ai/Learn See the employee table. Each column stores a particular attribute. Each row stores data of one employee. Employee_Name Employee_Id Designation Seema Rathod 123344 Manager G Balakrishnan 144555 Software Engineer Asif Iqbal 134455 Senior Architect Tina Das 157772 Business Analyst 3 Table: Employee
  • 4. Spotle.ai Study Material Spotle.ai/Learn 4 Using tables it is easy to model or store relationships between entities. For example, Spotle can have a user table, a course table and a user x course table that maps users to courses they are enrolled in. User_id User_name Course_id Course_name User_id Course_id User Course User_x_course
  • 5. Spotle.ai Study Material Spotle.ai/Learn How Do You Arrive At The Tables You Need? 5
  • 6. Spotle.ai Study Material Spotle.ai/Learn Step 1: Understand the Problem Statement 6
  • 7. Spotle.ai Study Material Spotle.ai/Learn 7 Problem Statement: I want to develop a student application which will have data of students, their courses and marks.
  • 8. Spotle.ai Study Material Spotle.ai/Learn 8 Step 2: Derive the major entities whose information you will need to store. The question you ask is: What information do I need?
  • 9. Spotle.ai Study Material Spotle.ai/Learn 9 Step 2: You can do this by underlining the nouns in your problem statement. Let’s revisit our problem statement:
  • 10. Spotle.ai Study Material Spotle.ai/Learn 10 Problem Statement: I want to develop a student application which will have data of students, their courses and marks.
  • 11. Spotle.ai Study Material Spotle.ai/Learn 11 Step 2: So you have got 3 entities: student, marks of students, courses subscribed by students. These become your tables. You may need some more (or less) tables which we discover in next steps.
  • 12. Spotle.ai Study Material Spotle.ai/Learn 12 Step 3: Turn entity attributes into columns: Determine the information you will store about each entity. These attributes become table columns.
  • 13. Spotle.ai Study Material Spotle.ai/Learn 13 Student Attributes: Name Roll_Number Phone_number Email_address Challenge: Think and share what other attributes you will want to store about a student?
  • 14. Spotle.ai Study Material Spotle.ai/Learn 14 Course Attributes: Course Name Course Description Course Instructor Name Course Subject Course Difficulty Level Image Challenge: Think and share what other attributes you will want to store about a course?
  • 15. Spotle.ai Study Material Spotle.ai/Learn 15 Step 4: Determine primary keys for each table. A primary key is the attribute that uniquely identifies each record in a table.
  • 16. Spotle.ai Study Material Spotle.ai/Learn A student has a unique roll_no. We can designate roll_no as the primary key. 16 Table: Student Student_Name Roll_No Email_Id Seema Rathod 123344 Manager G Balakrishnan 144555 Software Engineer Asif Iqbal 134455 Senior Architect Tina Das 157772 Business Analyst
  • 17. Spotle.ai Study Material Spotle.ai/Learn In the list of course attributes, we do not have a unique identifier. (Course names can be same for example 2 courses on Biology with different difficulty levels). So we give course a unique id and add it to the table. 17 Table: Course Course_id Course_Name Course_desc Course_level 1 Certificate In Biology Basic Biology Beginner 2 Certificate In Biology Advanced biology Advanced 3 English Level 1 Basic English Beginner 4 Mathematics Refresher Advanced Maths Advanced
  • 18. Spotle.ai Study Material Spotle.ai/Learn 18 Step 5: Model relationships between tables You may need to derive additional tables to store the relationships. In our example, we derived a student_x_course table to store which student has taken what course. Student Course Roll_no Course_id Student_x_course
  • 19. Spotle.ai Study Material Spotle.ai/Learn 19 Step 6: Normalise Tables Normalisation is the database technique of reducing redundancy and dependency in data by systematically splitting tables.
  • 20. Spotle.ai Study Material Spotle.ai/Learn Suppose a course has multiple instructors. How will you store the information? You can add another row for the course but then the primary key is repeated causing design to break. Also all course details are repeated unnecessarily. 20 Table: Course Course_id Course_Name Course_desc Course_level Instructor Name 1 Certificate In Biology Basic Biology Beginner Md Rafi 1 Certificate In Biology Basic Biology Beginner Kishor Ganguly 2 Certificate In Biology Advanced biology Advanced Asif Iqbal 3 English Level 1 Basic English Beginner Smriti K 4 Mathematics Refresher Advanced Maths Advanced Sam Joseph
  • 21. Spotle.ai Study Material Spotle.ai/Learn 21 Table: Course Course_id Course_Name Course_desc Course_level 1 Certificate In Biology Basic Biology Beginner 2 Certificate In Biology Advanced biology Advanced 3 English Level 1 Basic English Beginner 4 Mathematics Refresher Advanced Maths Advanced Instructor_Id Instructor _Name 1 Md Rafi 2 K Ganguly 3 Asif Iqbal 4 Smriti K 5 Sam Joseph Course_x_instructor_ id Course_id Instructor_id 1 1 1 2 1 2 3 2 3 4 3 4 5 4 5 Normalised design where the larger course table is split into a course table and instructor table. Their relationship is stored in a third table: the course_x_instructor table. Table: Course_x_Instructor Table: Instructor
  • 22. Spotle.ai Study Material Spotle.ai/Learn 22 Constraints are used to ensure integrity of the data in the database. Spotle.ai Study Material Spotle.ai/Learn 22 Table Constraints
  • 23. Spotle.ai Study Material Spotle.ai/Learn 23 Constraints are used to ensure integrity of the data in the database. They are imposed on table columns to enforce certain rules on the data ensuring integrity, accuracy and reliability. Constraints
  • 24. Spotle.ai Study Material Spotle.ai/Learn 24 1. Primary Key 2. Unique 3. Not Null 4. Foreign Key 5. Default Constraint 6. Check Constraint 7. Index Types Of Constraints
  • 25. Spotle.ai Study Material Spotle.ai/Learn 25 Primary Key: A primary key is a table column (or combination of columns) used to uniquely identify every record in the table. A primary key value has to be unique and not-null for every row in the database. For example, the roll_no in the student table.
  • 26. Spotle.ai Study Material Spotle.ai/Learn 26 Foreign Key: A foreign key is a column or group of columns in a table links records between data in two tables. It creates a cross-reference between tables by referencing the primary key of another table.
  • 27. Spotle.ai Study Material Spotle.ai/Learn 27 Table: Course Course_id Course_Name Course_desc Course_level 1 Certificate In Biology Basic Biology Beginner 2 Certificate In Biology Advanced biology Advanced 3 English Level 1 Basic English Beginner 4 Mathematics Refresher Advanced Maths Advanced Instructor_Id Instructor _Name 1 Md Rafi 2 K Ganguly 3 Asif Iqbal 4 Smriti K 5 Sam Joseph Course_x_instructor_ id Course_id Instructor_id 1 1 1 2 1 2 3 2 3 4 3 4 5 4 5 The course_id in the course_x_instructor table is a foreign key referencing the course_id in Course table. The instructor_id in the course_x_instructor table is a foreign key references the instructor_id in the Instructor table. Table: Instructor Table: Course_x_Instructor
  • 28. Spotle.ai Study Material Spotle.ai/Learn 28 1. Unique – enforces that the column value is unique for every row. 2. Not Null – enforces that the column value is not null for any row. 3. Default Constraint – prescribes a default value of the column which is used to populate any new row. The default value can be over-written. 4. Check Constraint – designates a pre- condition that the column data must adhere to. More Constraints Explained
  • 29. Spotle.ai Study Material Spotle.ai/Learn 29 Indexes are used to retrieve data from the database fast. An index is a pointer to data in a table that the database search engine uses to speed up select queries. Indexes are created on columns which are more likely to be used in search queries or after the where condition in the select statement. For example if you are likely to look up the Course table based on course_name you will create an index on name. Databases automatically create indexes on columns corresponding to primary keys and unique constraints. Any custom index you need has to be create with the Create Index command as shown: Create Index Course_Name on Course; Note: Indexes speed up select queries but slow down insert and update statements as any insert or update will need an update of the corresponding index too. Indexes