Introduction to Relational Model Flashcards

1
Q

What are various attribute types in the Relational Model?

A
  • char(n). Fixed length character string, with user-specified length n
  • varchar(n). Variable length character strings, with user-specified maximum length n
  • int. Integer (a finite subset of the integers that is machine-dependent)
  • smallint(n). Small integer (a machine-dependent subset of the integer domain type)
  • numeric(p, d). Fixed point number, with user-specified precision of p digits, with d
    digits to the right of decimal point. (ex., numeric(3, 1), allows 44.5 to be stores
    exactly, but not 444.5 or 0.32)
  • real, double precision. Floating point and double-precision floating point numbers,
    with machine-dependent precision
  • float(n). Floating point number, with user-specified precision of at least n digits
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Super Key?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Candidate Key?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Primary Key?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Surrogate Key?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a Composite Key?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a Secondary Key?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a Foreign Key?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a Compound Key?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Procedural Programming? vs Declarative Programming?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the domain of an attribute?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are atomic attributes?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is “Select” Relational Operation ?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is “Project” Relational Operation ?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is “Union” Relational Operation ?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is “Difference” Relational Operation ?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is “Intersection” Relational Operation ?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is “Cartesian Product” Relational Operation ?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is “Natural Join” Relational Operation ?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What are aggregate operations?

A

◦ SUM
◦ AVG
◦ MAX
◦ MIN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are the basic properties of relations?

A

Relation is a set, so, no ordering, no duplicates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is a composition of relational operations?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How to create a table in SQL?

A

create table instructor (
ID char(5),
name varchar(20)
dept name varchar(20)
salary numeric(8, 2));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How to order the display of tuples in SQL?

25
How to select Number of Tuples in Output?
26
How to deal with Duplicates in SQL?
Select distinct - displays unique values Select all - displays all values including duplicates
27
How to implement Union Set Operation in SQL?
28
How to implement Intersect Set Operation in SQL?
29
How to implement Difference Set Operation in SQL?
30
How to deal with "NULL" values?
31
What are some of the frequently used aggregate functions in SQL?
32
How to group using an aggregate attribute in SQL?
33
How to set conditions of an aggregating attribute in SQL?
34
What are Instances in databases?
The actual data present in the database at that point of time.
35
What are Turing Complete Languages? Is SQL turing complete?
A programming language is considered Turing complete if it can express any computation that a Turing machine can perform. This means that the language provides the necessary constructs and features to implement any algorithm or computation, even if it might not be practical to do so. SQL is NOT Turning Complete Language
36
What are Integrity Constraints of an attribute?
Primary Key, Unique, Not Null, Auto Increment, Foreign Key etc are some of the integrity contraints of an attribute
37
how to check set membership in SQL?
Using "in" query select * from student in ('CSE');
38
What are the string operations possible in SQL
1) Like - with % wildcard for multiple characters and _ wildcard for single character
39
How to sort the output of a query in SQL?
using "order by " clause.. we could set it to "ASC" or "DESC" or one option per atribute
40
How to create temporary /permanent relations in a database that hides certain information from users
Create view v as one view could be dependent on the other.That is, composition is possible.
41
What are transactions?
42
How to evaluate a predicate in SQL
Using "Check" clause.. check(semester in ('Fall','Winter','Spring','Summer')
43
What is referential integrity? how is it ensured in SQL
Foreign Key.. on delete_cascade; on update cascade; Alternative actions to cascade: no action, set null, set default.
44
How to create an index in SQL?
Create idx_student_id on Student(Student_id)
45
How to create user defined data types in SQL
create type Dollars as numeric(12,2) final
46
How to create domains in SQL
create domain person_name char(20) not null. Allows us to specify integrity constraints unlike user defined data types.
47
What are some of large object Types
1. BLOB 2. CLOB
48
What are forms of authorization on parts of the database?
1. Read 2. Write 3. Update 4. Delete
49
What are forms of auhorization to modify the database schema
1. Index 2. Resource 3. Alteration 4. Drop
50
How to grant authorization in SQL
grant on to where previleges could be select, insert, update,delete, all privileges. user list could be user id, role or public.
51
How to cancel authorization in SQL?
revoke on from
52
How to create roles in SQL
create role grant to Madhan we could chain the roles create role grant role_name to role2 Previleges could also be transferred. grant select on dept to Madhan with grant option revoke select on dept from Amit cascade
53
How to grant privelege for created foreign keys?
grant reference (dept_name) on department to Madhan
54
How are functions defined in SQL?
create function dept_count(dept_name varchar(20)) returns integer begin declare d_count integger; select count(*) into d_count from instructor whare instructor.dept_name =dept_name return d_count; end Functions could return a table itself.
55
How to loop in SQL
while loop: while do sequence of statements end while; repeat loop: repeat sequence of statements until end repeat for loop: for r as select budget from department do set n=n+r.budge end for;
56
Branching Statements in SQL
if-then-else : if then sequence of statements; elseif then sequence of statements; else sequence of statements end if; case: case when sql-expr =value1 then sequence of statemetns; when sql-expr=value2 then sequence of statemetns; else sequence of statemetns; end case;
57
exception handling in SQL
declare out_of_classroom_seats condition declare exit handler for out_of_classroom_seats begin ...... signal out_of_classroom_seats ....... end
58
What are external language routines
SQL allows the definition of functions/ procedures in an imperative programming language like Java, C, C# etc which can be invoked from SQL queries. create procedure dept _coutn_proc(in dept_name varchar(20),out count integer) Language C external name '/usr/avi/bin/dept_count_proc/ create function dept_count(dept_name varchar(20)) returns integer language C external name '/usr/avi/bin/dept_count'