Computer Science
Level #3
Chapter #2
Database
2020
Q1. What is the difference between Flat-file and relational database?
Flat File:
Contains only one table for all data.
Result in high levels of data redundancy.
Example:
Relational database:
Is a relationship among relations (Tables).
Consists of a collection of tables, each of which is assigned a unique name.
Example:
Q2. Define each of the following:
1) SQL: Structured Query language is the database communications language
managed by the ANSI organization.
2) Attribute, Filed: Column in a table.
3) Domain: The set of allowed values for each attribute.
4) Tuple, Record, instance: is a row in a table.
1 DataBase 2020
5) Index: A collection of data and reference information used to locate records
more quickly in a table.
6) View: One of the objects in databases. A stored SQL SELECT statement, used to
make data access simple.
7) A trigger: A group of SQL statements that executed automatically when specified
events occur.
8) Relation schema: Consists of name of a table and list of its attributes.
Q3. What is the difference between Super Key, candidate key, primary key
and foreign key?
عبارة عن مجموعة األعمدة (عمود واحد او اثنين او اكثر ( والتي من الممكنSuper Key
.ان تعرف أي صف فريد داخل الجدول
يتم اختياره كمفتاحSuper Key األقل في عدد األعمدة داخل الCandidate key
.مرشح
Candidate Key هو العمود الذى يتم اختياره من الـPrimary Key
PK ⊂ CK ⊂ SK
عباره عن عمود ال بد ان يكون مفتاح أساسي في جدول اخر ويكونForeign key
.من نفس النوع ويستخدم ف العالقة بين الجدولين
Q4. State conditions of primary key and foreign key.
Primary Key Must Be
[1] Unique.
[2] Required.
[3] Indexed.
Foreign Key must be:
[1] Values in a relation contains F.k must be in a relation contain P.K.
[2] F.K reference to P.K must have the same data type.
2 DataBase 2020
Q5. Rewrite the following queries using relational algebra and write output.
3 DataBase 2020
4 DataBase 2020