Become A SQL Developer (LinkedIn) Flashcards
What is CRUD?
Create, Read, Update, Delete
What does ACID relate to?
It relates to completing a transaction so that all elements are completed or none at all e.g. debiting a bank account and crediting another
What does ACID stand for?
Transactions should follow a set of principles. Transactions must be:
Atomic - the transaction is indivisible. It cannot be separated out.
Consistent - whatever the transaction does, it must leave the database in a valid or consistent state. Integrity should not be violated.
Isolated - while the activities in the transaction are being completed, nothing else can make changes to the data involved.
Durable - the information that we change during the transaction, actually gets written to the database.
What is a transaction?
It’s a type of setup that tells the RDBMS that all CRUD elements must be complete or none at all.
What’s the first step in building the database?
Ask what data it needs to store. What are the entities, attributes, datatypes, and keys (primary, foreign and composite?
What kind of diagram is good for a database?
Entity Relationship Diagram (ERD)
What are the naming conventions for table and attribute names
Table name - Start with a capital letter and use the plural as in Customers
Attributes - use upper camel case and use singular
What’s the difference between CHAR and VARCHAR
VARCHAR will store up to the number of characters you tell it but CHAR will reserve that amount in memory every single time - a huge impact when dealing with very large databases.
What are two data types that we can use for the date - what’s the difference?
DATE and DATETIME - the latter stores the time also
Show a decimal datatype with 3 digits before the decimal and 2 after?
DECIMAL(3,2)
What does NULL mean?
It means the absence of a value
What are the next steps (step 2) in creating the database?
Start looking at the relationships between the tables/entities.
What is a one to many relationship.
It is where one row of a table connects to more than one row of another table e.g. a customer table and food dishes table. A food dish can appear many times on the customer’s tables (when we log their favourite dish). One dish may be the favourite of many customers. The foreign key will be on the many side i.e. on the customer’s side. It will appear many times in the customers table (in the favourite dish column)
What is a cascading delete?
Is where you delete a record and the database goes on and deletes other records associated with that record?
What is the third step in creating the database?
Normalize the database