Databases & ORMs Flashcards

(22 cards)

1
Q

What is a Database?

A

The database is a collection of information that is organized so that it can be easily be accessed, managed and updated.

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

What is a DBMS

A

DBMs are Database Management system

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

What does DBMs do?

A

Access a database
Manipulate data
Helps control access to the database by various users

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

What is a relational database?

A

It is a collection of data items organized as a set of tables from which data can be accessed and reassembled in many ways without having to reorganize the database tables.

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

What is a relational database?

A

It is a collection of data items organized as a set of tables from which data can be accessed and reassembled in many ways without having to reorganize the database tables.

Meaning:

  • Each table contains data in predefined columns
  • Each row contains a unique instance of data defined by the columns
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are data models?

A

The data model is a framework that describes what relation the different tables have with each other.

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

What is ERD?

A

It stands for entity-relationship diagram

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

What is an entity?

A

a real-world object/items with properties called attributes,
Every attribute is defined by its set of values called domain

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

What is an entity?

A

a real-world object/items with properties called attributes,
Every attribute is defined by its set of values called domain

Example:
Costumer (entity) <=> name, adress, phone number (attributes)

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

What is a relationship?

A

Relationships are logical associations among entities

Example:
1 - 1 ( customer has one id number )
1-many ( customer has many orders )
many - 1
many - many
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a Diagram?

A

a diagram shows the relationships in a graphical way:
A box is an entity
inside the box we have the attributes of that entity
and lines that connects the different boxes.

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

What is SQL?

A

Structured Query Language is the language to maintain data in relationship database

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

How do we interact with data in this course?

A

We use ORM

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

What is ORM?

A

Object Relational Mapping
Is a system which allows to connect objects (instances of classes) It allows us to interact with databases without using SQL

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

How does ORMs work?

A
ORM libraries map database tables to classes
Example 
If a database has a table called costumer, our program wioll have a class named Customer. 
The rows in the table will corresponds to the instances of the class Costumer.

Whenever you create a new class of an Costumer a new row will be created in the table.

Inside the object attributes are used to get and set each column

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

What is ActiveRecord?

A

It is a ORM Library

17
Q

What does ActiveRecord do?

A
  • Represents models and their data ( enteties)
  • Represents associations between these models
  • Represents inheritance hierarchies through related models
  • Validates models before they get persisted to the database
  • Perform database operations in an object-oriented way.
18
Q

What are some Naming conventions between databases?

A

Database table = plural & snake_case people, order_items, articles
Model Class = Singular & CamelCase

19
Q

What are some Schema Conventions?

A

Foreign Keys: singular & snake_case

Primary keys: Automaticly

20
Q

What are primary keys?

A

Primary keys is a candidate key with no null values

21
Q

What is a candidate key?

A

A candidate key is a column, or set of columns, in a table that can uniquely identify any database record without referring to any other data. Each table may have one or more candidate keys, but one candidate key is unique, and it is called the primary key.

22
Q

What is a Foreign key?

A

Its an id that is referenced in another table

https://www.youtube.com/watch?v=dunrd3MKl1Y