Database Modelling: Tables Flashcards
What is a schema?
This is the formal description of our database
This includes; columns, tables, keys, values etc.
Very important to plan schema to ensure smooth sailing from the very start of the database being online
Questions to ask when starting database schema?
- What’s the point? Be specific and ensure you understand the INTENTION of the database! What problem does the database solve?
- What do you already have? Is there any infrastructure that is to be replaced or worked on top of/with? Are there any people and resources that you need or already have to help with the development of database?
First REAL question to ask when designing database?
- What entities will we have? Which objects need to be represented with a table. E.g. customers, oders, products, authros, employess. Use the most basic and simple words at the beginning
NOTE: When naming tables based on these entities EITHER use singular (preferred) or plural
What are out main concerns with our database?
- Which entities we will have
- How we will represent these entities
- How we will draw relationships between these entities and their representations.
NOTE: This is known as entity-relationship modelling
What is our second question to ask?
What are our attributes that we will assign to each entity?
Attributes can start relatively simple at the start of planning BUT they should be specific.
Have to determine a naming convention for each of the attributes AND STAY CONSISTENT
Once entities and attributes have been determined, what is the next step?
Determine the data types for each attributes. Data types should be specific as DBMS require these to be specified.
E.g. character, date, integer, binary (audio, video, images) etc.
What are BLOBs?
These are Binary Large Objects
These are data types that include images, videos and audio
What are CLOBs?
These are Character Large Objects
These are data types that contain large sums of strings/text/characters
What is a NULL value?
A NULL value states that there is a complete absence of a value within a table. Different from just zero.
Choosing a primary key?
Primmary keys need to be added to tables to allow us to search for rows. They should be unique values to prevent confusion
Primary keys can be natural (an inherently unique value that is already an attribute in the table) OR can be synthetic (randomly generated number / unique value which ONLY acts as a primary key)
What is a composite key?
This is when we use two OR more values within a table to create a unique primary key.
Can be used when joining tables together with a junction/linking table to form many-to-many relationships