blairbasheng / quotes

MIT License
0 stars 1 forks source link

Determine Database Schema, Calculate Database Size #1

Closed sahwho closed 11 months ago

sahwho commented 11 months ago

Start by reading: https://www.educative.io/blog/what-are-database-schemas-examples

This resource is also good: https://dba.stackexchange.com/questions/18607/how-to-estimate-database-size-needed

Using a reference like https://www.w3schools.com/sql/sql_datatypes.asp, determine the schema (aka data type for each column) that we'll use for our SQL database of quotes that have already been scraped from BlairBash (csv file available here: https://raw.githubusercontent.com/blairbasheng/quotes/main/quotes.csv).

Do a rough estimate of the "size" of the database (MB).

cemeterysummoning commented 11 months ago

Schema: timestamp: DATETIME (8 bytes) score: SMALLINT (2 bytes) votes: UNSIGNED SMALLINT (2 bytes) quote: NVARCHAR (4 bytes + 170 bytes/character on average) note: NVARCHAR (4 bytes + 21 bytes/character on average) tags: NVARCHAR (4 bytes + 18 bytes/character on average)

Size per row: 233 bytes Total rows: 9559

Total size: 9559 * 233 = 2.23 MB

jania210 commented 11 months ago

Timestamp (datetime) = 8 bytes Score (smallint) =2 bytes Votes (smallint) = 2 bytes Quote (text) = 4 bytes + average char (169) Notes (text) = 4 bytes + average char(19) Tags (text) = 4 bytes + average char(18)

Per row : 230 Number of Rows : 9560 1 megabyte = 1,048,576 bytes

Total size : 2,198,800 bytes = 2.097 MB

BryanR294 commented 11 months ago

Assuming Database Size of 10,000 Database Size: 2.24 MB

Calculation: Timestamps = DATETIME(8 bytes) Score = SMALLINT(2 bytes) Votes = SMALLINT(2 bytes) Quote = VARCHAR(2 bytes + avg char 169) Notes = VARCHAR(2 bytes + avg char 19) Tags = VARCHAR(2 bytes + avg char 18)