Database Terms
Database Terms
Vertical: Columns/Fields/Attributes = 2
Horizontal: Rows/Records/Tuples = 7 (Excluding the first one, as first row always represents the field
names)
Data Types:
1) STRING
Alphanumeric…alphanumeric+symbols
Haseeb…haseeb123…[email protected], IDS, Serial Numbers
IDS, Serial Numbers (Non-calculative)
VARCHAR(10)
2) INTEGER
Whole number
3) REAL
Fractional part
4) BOOLEAN
Two states (BIT)
5) DATE
Any date
6) TIME
Any time
Primary Key: (KEY…FIELD) (Serial Numbers/IDs)
A field in a table that is unique and can be used to distinguish in between different records of
the table.
NOTE : All the entities in a relational data base are linked with each other.
Relationship Types:
1) One to one
2) One to Many
3) Many to One
4) Many to Many
Candidate Key:
1) Primary Key
Unique/No repetitions
2) Candidate Key
Could have been selected as a primary key, wasn’t unique but is still able to search through the
table. Example: People use names to search.
Students:
Foreign Key: A key in a table that is used to interlink the tables or it is connected to the primary key of
another table.
Process of storing the data in an organized way based on at least two tables, interlinked with each other,
i.e., they must have a relationship in between them to reduce data repetition.
1) Primary Key
2) No Groups
3) Reduced data repetition
1) 1st Normal
2) No Partial Dependencies
When a field in a table isn’t dependent on primary key, but is dependent on composite key.
Composite Key: Primary key made up of two fields is a composite key.
1) Primary Key
2) No Groups
3) Reduced data repetition
1) 1st Normal
2) No Partial Dependencies
When a field in a table isn’t dependent on primary key, but is dependent on composite key.
Composite Key: Primary key made up of two fields is a composite key.
Score Table:
Score ID Subject ID Student ID Marks Teacher
1 10 1 81 Haseeb
2 10 2 91 Husain
3 11 1 87 Hasan
4 11 2 56 Haseeb
5 11 1 43 Hamza
6 11 2 31 Husain
Marks Table:
Marks ID Marks Subject ID Student ID
1 81 10 1
2 91 10 2
3 87 11 1
4 56 11 2
5 43 11 1
6 31 11 2
Exam Table:
Exam ID Exam Type Marks
1 Assessment 20
2 Class Test 10
3 MOCKS 100
4 Viva 40
New Exam Table:
Exam ID Exam Type
1 Assessment
2 Class Test
3 MOCKS
4 Viva
Marks Table:
Marks ID Marks Exam ID
1 20 1
2 10 2
3 100 3
4 40 4