1 Oracle and Structured Query Language (SQL)

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/44

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

45 Terms

1
New cards

What is an Entity-Relationship Diagram (ERD)?

A logical model of a business showing entities and their relationships.

2
New cards

What’s the difference between TRUNCATE and DELETE?

TRUNCATE:

  1. requires at least ALTER permission on the table

  2. DDL

  3. logs only deallocation of data pages

  4. faster

  5. cannot be rollbacked

  6. doesn’t activate triggers

  7. no WHERE condition, removes all rows, resets auto-increment value

DELETE:

  1. requires DELETE permissions on the table

  2. DML

  3. logs each row deletion

  4. slower

  5. can be rollbacked

  6. can activate triggers

3
New cards

What’s a relational database?

It’s a physical implementation of ERD. It’s how the ERD’s data, relations, constraints, etc are stored.

4
New cards

What’s the notation for representing relationships in database modeling?

Crow’s Foot notation

5
New cards

What’s the symbol in Crow’s Foot notation for “Exactly one”?

-|-|—————

6
New cards

What’s the symbol in Crow’s Foot notation for “Zero or one”?

-|-0—————

7
New cards

What’s the symbol in Crow’s Foot notation for “Zero, one or more”?

→0————

8
New cards

What’s the symbol in Crow’s Foot notation for “One or more”?

→|—————

9
New cards

How are ERD entities implemented in a relational database?

Entities become tables; entity attributes become columns.

10
New cards

What is a primary key?

A unique and not null identifier for each row in a table.

11
New cards

What is a foreign key?

A column in one table that references the primary or unique key in another table to establish a relationship. Foreign key is a copy of all columns that are part of the constraint in a second table so that the second table can relate to the first. They must have matching data types and order

12
New cards

How are many-to-many relationships handled in relational design?

They are replaced with a third entity (junction/association table).

13
New cards

Is it possible to have a many-to-many relationship in a physical model in database?

No, There is never a many-to-many relationship in a finished physical model.

14
New cards

What is database normalization?

The process of structuring a database to reduce redundancy and improve integrity.

15
New cards

What does First Normal Form (1NF) require?

Tables must not contain repeating groups; all attributes must be atomic.

16
New cards

What does Second Normal Form (2NF) require?

No non-key attribute should depend only on part of a composite key.

17
New cards

What does Third Normal Form (3NF) require?

No transitive dependencies; all non-key attributes depend only on the primary key.

Mostly to divide many-to-many relationships into one-to-many-to-one relationships.

Primary key values are associated only with logically related attributes, and other data such as lookup data is moved to separate tables.

18
New cards

What does BCNF (Boyce-Codd) normal form require?

It’s a slightly modified version of 3NF designed to eliminate structures that might allow some rare logical inconsistencies to appear in the data. It’s in 3NF, X should be a super-key for every functional dependency (FD) X → Y in a given relation. To test whether a relation is in BCNF, we identify all the determinants and make sure that they are candidate keys.

19
New cards

What does Fourth Normal Form (4NF) require?

BCNF plus additional logic to ensure that every multivalued dependency is dependent on a superkey.

20
New cards

What does Fifth Normal Form (5NF) require?

4NF plus every join dependency for the table is a result of the candidate keys.

21
New cards

When are 3NF designs ideal?

When minimizing duplicate data and conflicts during data entry and updates. They are ideal when lots of data entry and updates are involved. Most transaction-based DB apps are in 3NF.

22
New cards

When might denormalized designs (1NF/2NF) be preferred?

For reporting, big data, data warehouses, or read-heavy systems where performance is prioritized. Small or none updates are on the records. 1NF or 2NF are also known as denormalized.

23
New cards
24
New cards

What is a database in the context of applications?

A persistent store of data that exists beyond the execution of an application.

25
New cards

What is SQL?

The industry-standard language for creating and interacting with relational databases.

26
New cards

Can SQL be called from other programming languages?

Yes, languages like Java, PHP, etc., can embed and issue SQL statements.

27
New cards

Which Oracle tools are commonly used to execute SQL?

SQL*Plus and SQL Developer.

28
New cards

How is SQL pronounced?

Either 'ess-cue-ell' or 'sequel'; both are correct.

29
New cards

What does DDL stand for?

Data Definition Language.

30
New cards

What is the purpose of DDL?

To create, alter, and drop database objects, and manage privileges and metadata.

31
New cards

Which SQL statements belong to DDL?

  • CREATE - user, table, view, index, synonym, or other object

  • ALTER - modifies existing object

  • DROP - removes object

  • RENAME

  • TRUNCATE - removes all rows from table. Gives up recovery options.

  • GRANT - provides privileges, rights to user objects to enable them to perform some tasks

  • REVOKE - removes privileges that have been granted

  • FLASHBACK - restores an earlier version of a table or database

  • PURGE - irrevocably removes database objects from the recycle bin

  • COMMENT - adds comments to the data dictionary for an existing object

32
New cards

Why is TRUNCATE considered DDL and not DML?

It removes all rows without recovery options, unlike DELETE, and commits immediately.

33
New cards

What does DML stand for?

Data Manipulation Language.

34
New cards

What is the purpose of DML?

Data manipulation language is there to add, modify, view, and delete data in database objects.

35
New cards

Which SQL statements belong to DML (Data manipulation language)?

  • SELECT - retrieves data from a table

  • INSERT - adds new data to a table

  • UPDATE - modifies existing data in a table

  • DELETE - removes existing data from a table

  • MERGE - combines INSERT, UPDATE, and DELETE into one statement

36
New cards

What is MERGE used for?

To combine INSERT, UPDATE, and DELETE in one statement.

37
New cards

What does TCL stand for?

Transaction Control Language.

38
New cards

Which statements belong to TCL?

COMMIT, ROLLBACK, SAVEPOINT.

39
New cards

What does COMMIT do?

Saves all DML changes made in the current session.

40
New cards

What does ROLLBACK do?

Undoes DML changes made in the current session since the last COMMIT.

41
New cards

What does SAVEPOINT do?

Marks a point in a transaction to roll back to without undoing the entire transaction.

42
New cards

Which SQL statements cause an implicit COMMIT?

Any DDL statement.

43
New cards

What is the purpose of the SELECT statement?

To query and retrieve data from one or more tables.

44
New cards

Can SELECT modify data?

No, SELECT only retrieves data; it does not change the underlying data.

45
New cards

What can SELECT do beyond simple retrieval?

Join multiple tables, filter rows, transform data, aggregate results.