Download Relational Database Concepts

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

SQL wikipedia , lookup

Concurrency control wikipedia , lookup

Database wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Clusterpoint wikipedia , lookup

Relational algebra wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Ingres (database) wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Join (SQL) wikipedia , lookup

Relational model wikipedia , lookup

Database model wikipedia , lookup

Transcript
Relational Database Concepts
22-May-17
db.ppt
relational database example
•contain tables
•tables contain records (rows)
•records are broken into
columns (fields)
22-May-17
PK_ID
Quote
FK_Sources
1
I don’t like that man; I must get to know
him better.
4
2
I wish I had an answer to that because
I'm tired of answering that question.
1
3
Right is right, even if everyone is against
it, and wrong is wrong, even if everyone
is for it.
3
4
People are just as happy as they make
up their minds to be.
4
db.ppt
first design for the MyQuotes database
Quotes table:
PK_ID
22-May-17
QuoteBody
1
I don’t like that man; I
must get to know him
better.
2
I wish I had an answer to
that because I'm tired of
answering that question.
QuoteSource
Abraham
Lincoln
Yogi Berra
3
Right is right, even if
everyone is against it, and
wrong is wrong, even if
everyone is for it.
William Penn
4
People are just as happy as
they make up their minds
to be.
Abe Lincoln
db.ppt
•Are records
1 and 4 from
the same
source?
a better design for the MyQuotes database
Quotes1 table:
PK_ID
1
Quote
FK_Sources
I don’t like that man; I
must get to know him
better.
4
2
I wish I had an answer to
that because I'm tired of
answering that question.
1
3
Right is right, even if
everyone is against it, and
wrong is wrong, even if
everyone is for it.
3
4
People are just as happy as
they make up their minds
to be.
4
Sources1 table:
PK_SourceID
Source
1
Yogi Berra
2
Mark
Twain
3
William
Penn
4
Abraham
Lincoln
SELECT Quotes1.QuoteBody, Quotes1.FK_SourceID, Sources1.PK_SourceID, Sources1.SourceBody
FROM Quotes1, Sources1
WHERE Quotes1.FK_SourceID=Sources1.PK_SourceID
22-May-17
db.ppt
“inner join” SQL statement
SELECT Quotes1.QuoteBody, Quotes1.FK_SourceID, Sources1.PK_SourceID, Sources1.SourceBody
FROM Quotes1, Sources1
WHERE Quotes1.FK_SourceID=Sources1.PK_SourceID
theAnswer = myResultSet.getString(1) +
" " + myResultSet.getString(4);
“join” because it gets data from two different tables
“inner” because each table only returns matching records
22-May-17
db.ppt
tables represent “relationships”
• one to one relationship (1 table)
• a table of Persons may directly contain the social security
number
• one to many relationship (2 tables)
• a table of Sources
• a table of Quotes
• each Quotes record points to one Sources record
• many to many relationship (3 tables)
• a table of Persons
• a table of Skills
• a table of Person-Skills
• for each skill that a person has, there is a record here
• for each person that has a skill, there is a record here
22-May-17
db.ppt
Relational Database Concepts
•
•
•
•
Relationships
Contraints
Triggers
Stored procedures
•
Tables
•
Views
•
Indexes
•
Keys
•
•
•
•
Rows (Records)
Columns (Fields)
Clustered indexes
Non-clustered indexes
•
Primary keys
•
Foreign keys
•
Composite keys
•
Locking
•
Isolation Levels (for transactions)
22-May-17
•
•
•
optimistic
pessimistic
gets complicated!
db.ppt
the end of this PowerPoint file
Hooray!
22-May-17
db.ppt