投稿時間:2023-08-15 07:14:14 RSSフィード2023-08-15 07:00 分まとめ(19件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
技術ブログ Developers.IO 『イベントの記録』を取っておく(撮っておく)ことの大切さ #devio2023 https://dev.classmethod.jp/articles/keeping-records-of-events-is-very-important/ developersio 2023-08-14 21:50:00
海外TECH Ars Technica Dell fined $6.5M after admitting it made overpriced monitors look discounted https://arstechnica.com/?p=1960737 australia 2023-08-14 21:09:46
海外TECH MakeUseOf 8 Ways AI Blurs the Line Between Reality and Fantasy https://www.makeuseof.com/ways-ai-blurs-line-between-reality-and-fantasy/ incredible 2023-08-14 21:45:23
海外TECH MakeUseOf 3 Ways to Contact an Amazon Seller https://www.makeuseof.com/contact-amazon-seller/ amazon 2023-08-14 21:30:22
海外TECH DEV Community A Better Way To Store Record Status In A Relational Database https://dev.to/houseman/a-better-way-to-store-record-status-in-a-relational-database-2ik1 A Better Way To Store Record Status In A Relational DatabaseRelational database records often require transitions between various statuses for example active pending deleted etc Various database structures may be used to store this status A Naive SolutionThe most naive database design would simply store this status field as a varchar type PostgresDROP TABLE IF EXISTS product CASCADE CREATE TABLE product product id SERIAL PRIMARY KEY title VARCHAR NOT NULL sku VARCHAR NOT NULL status VARCHAR NOT NULL A Better SolutionThis improved solution makes use of an ENUM type to define status PostgresDROP TYPE IF EXISTS product status CASCADE CREATE TYPE product status AS ENUM in stock on order unavailable deleted DROP TABLE IF EXISTS product CASCADE CREATE TABLE product product id SERIAL PRIMARY KEY title VARCHAR NOT NULL sku VARCHAR NOT NULL status product status This limits the possible value of status to one of in stock on order unavailable or deleted There are several benefits of using an enum type over a varchar Data Integrity ensure that the value is always within a specific set of values This is not possible with varchar unless you add a CHECK constraint Performance enum values are internally sorted according to their order in the enum type declaration not their lexicographical order This can lead to more efficient sorting and indexing Readability enum types can make your code more readable and self documenting by making it clear what values are allowed for a field Storage enum values are stored as integers which can be more space efficient than varchar However adding new values to an enum type requires an ALTER TYPE statement which can be a heavy operation if your database is large MetadataThese enum status values have the following semantics with regards to a Product ValueIn warehouse stockOn back orderBuyableVisible in Order Historyin stockYesNoYesYeson orderNoYesYesYesunavailableNoNoNoYesdeletedNoNoNoNoThese now need to be implemented in business logic Something like status pyfrom future import annotationsfrom dataclasses import dataclass dataclassclass ProductStatus A data model for product status is in stock bool is on back order bool is buyable bool is active bool classmethod def create cls status str gt ProductStatus Create a ProductStatus instance derived from the given string match status lower case in stock return ProductStatus is in stock True is on back order False is buyable True is active True case on order return ProductStatus is in stock False is on back order True is buyable True is active True case unavailable return ProductStatus is in stock False is on back order False is buyable False is active True case deleted return ProductStatus is in stock False is on back order False is buyable False is active False case raise ValueError f Unable to determine product status status This works well enough but it does split the domain between the database and the code base It would be better if we could represent the state better within the database Add state columnsIn order to store these state values better in the database we could add a few columns to the product table PostgresDROP TABLE IF EXISTS product CASCADE CREATE TABLE product product id SERIAL PRIMARY KEY title VARCHAR NOT NULL sku VARCHAR NOT NULL is in stock BOOLEAN NOT NULL is on back order BOOLEAN NOT NULL is buyable BOOLEAN NOT NULL is active BOOLEAN NOT NULL This is an improvement as we now have status attributes for each product record But some limitations remain We cannot add any metadata to the various status flags We also would need to add further columns if we ever needed a status that requires additional state flags This would necessitate an ALTER operation on our large product table Normalise the databaseThe best solution would be to abstract product status from the product table To achieve this we normalise the database structure by adding a foreign key to a product status table PostgresDROP TABLE IF EXISTS product status CASCADE CREATE TABLE product status product status id SERIAL PRIMARY KEY product status usid VARCHAR NOT NULL UNIQUE unique string identifier description VARCHAR NULL is in stock BOOLEAN NOT NULL is on back order BOOLEAN NOT NULL is buyable BOOLEAN NOT NULL is active BOOLEAN NOT NULL DROP TABLE IF EXISTS product CASCADE CREATE TABLE product product id SERIAL PRIMARY KEY title VARCHAR NOT NULL sku VARCHAR NOT NULL product status id INTEGER NOT NULL FOREIGN KEY product status id REFERENCES product status product status id Next let s create records for the various status values and associated state flags PostgresINSERT INTO product status product status usid description is in stock is on back order is buyable is active VALUES in stock Product is in stock true false true true on order Product is on back order false true true true unavailable Product is unavailable false false false true deleted Product is deleted false false false false SELECT FROM product status Which gives us product status id product status usid description is in stock is on back order is buyable is active in stock Product is in stock t f t t on order Product is on back order f t t t unavailable Product is unavailable f f f t deleted Product is deleted f f f f rows And add some junk product data INSERT INTO product title sku product status id VALUES EcoBoost Portable Charger SKU ECB AquaPure Water Filter SKU AQPF SolarGlow Garden Lights SKU SGL FitFlex Yoga Mat SKU FFYM BreezeAir Conditioner SKU BAC CrispSound Bluetooth Speaker SKU CSBS SmoothBlend Juicer SKU SBJ QuickCook Microwave Oven SKU QCMO UltraView Binoculars SKU UVB ProFit Running Shoes SKU PFRS The value of a usidThe unique string identifier usid product status usid value is useful for reducing cognitive load when constructing queries For example SELECT product title product sku product status description statusFROM productJOIN product status ON product product status id product status product status idWHERE product status usid in stock title sku status EcoBoost Portable Charger SKU ECB Product is in stock BreezeAir Conditioner SKU BAC Product is in stock UltraView Binoculars SKU UVB Product is in stock ProFit Running Shoes SKU PFRS Product is in stock rows is far easier to understand at a glance thanSELECT product title product sku product status description statusFROM productJOIN product status ON product product status id product status product status idWHERE product product status id Similarly when referring to these foreign key records in code we do not want to use a primary key integer value as a constant as these are strictly speaking not constant identifier Rather we would want to use the usid for this Extensibility Adding a new statusShould we need to add a new status for example pre order to our system it is as simple as adding a new record to the product status table We may want to extend the structure for this as well Fortunately altering the product status table is far quicker and less risky than doing the same to the large product table PostgresALTER TABLE product statusADD COLUMN is pre order BOOLEAN NOT NULL DEFAULT false INSERT INTO product status product status usid description is in stock is on back order is buyable is active is pre order VALUES pre order Product is available for pre order false false true true true Adding a status logAnother benefit that this abstraction offers us is the ability to extend our architecture fairly easily For example to add a table to log status changes PostgresDROP TABLE IF EXISTS product status log CASCADE CREATE TABLE product status log product id INTEGER NOT NULL product status id INTEGER NOT NULL logged at TIMESTAMP WITH TIME ZONE DEFAULT now FOREIGN KEY product id REFERENCES product product id FOREIGN KEY product status id REFERENCES product status product status id CREATE INDEX idx product status ON product status log product id product status id And we have a nice logSELECT product status product status usid status log logged atFROM product JOIN product status log log ON product product id log product id JOIN product status ON log product status id product status product status idWHERE product sku SKU SGL ORDER BY log logged at ASC status logged at in stock on order in stock on order in stock unavailable deleted rows Cheers 2023-08-14 21:39:10
海外TECH CodeProject Latest Articles C++ OpenSSL 3.1 code to attack AES-CBC (Advance Encryption Standard with Cipher Block Chaining mode) using Padding Oracle Attack with Error Handling Attack an easy one and one of the side channel attacks namely Timing Attack a tougher one. https://www.codeproject.com/Tips/5366343/Cplusplus-OpenSSL-3-1-code-to-attack-AES-CBC-Advan C OpenSSL code to attack AES CBC Advance Encryption Standard with Cipher Block Chaining mode using Padding Oracle Attack with Error Handling Attack an easy one and one of the side channel attacks namely Timing Attack a tougher one Attack AES CBC using Padding Oracle Attack and Timing Attack 2023-08-14 21:41:00
海外TECH CodeProject Latest Articles How to do Multiple Assertions with Fluent Assertions? https://www.codeproject.com/Tips/5366616/How-to-do-Multiple-Assertions-with-Fluent-Assertio lines 2023-08-14 21:41:00
海外科学 NYT > Science Opioid Settlement Money Is Being Spent on Police Cars and Overtime https://www.nytimes.com/2023/08/14/health/opiod-settlement-money.html Opioid Settlement Money Is Being Spent on Police Cars and OvertimeAs states and counties spend the first wave of billions of dollars from the pharmaceutical industry public health groups are challenging how some funds are being used 2023-08-14 21:12:11
海外TECH WIRED 3 Best Deals From Roborock's Robot Vacuum Sale https://www.wired.com/story/roborock-robot-vacuum-deals-august-2023/ cheap 2023-08-14 21:23:00
海外科学 BBC News - Science & Environment Burning mangrove trees for a living: 'I'd quit tomorrow if I could' https://www.bbc.co.uk/news/world-asia-66393515?at_medium=RSS&at_campaign=KARANGA charcoal 2023-08-14 21:05:30
金融 ニュース - 保険市場TIMES T&Dフィナンシャル生命、静岡県が発行する「グリーンボンド」に投資 https://www.hokende.com/news/blog/entry/2023/08/15/070000 TDフィナンシャル生命、静岡県が発行する「グリーンボンド」に投資月日発表TDフィナンシャル生命保険株式会社以下、TDフィナンシャル生命は、静岡県が発行するグリーンボンド「静岡県第回公募公債グリーンボンド・年」に投資したと年月日に発表した。 2023-08-15 07:00:00
ニュース BBC News - Home Sara Sharif, 10, found dead in Woking house named locally https://www.bbc.co.uk/news/uk-england-surrey-66503514?at_medium=RSS&at_campaign=KARANGA surrey 2023-08-14 21:29:10
ニュース BBC News - Home Manchester United 1-0 Wolverhampton Wanderers: Raphael Varane heads winner https://www.bbc.co.uk/sport/football/66424895?at_medium=RSS&at_campaign=KARANGA Manchester United Wolverhampton Wanderers Raphael Varane heads winnerRaphael Varane heads a late winner against Wolverhampton Wanderers as Manchester United make a winning start to the new Premier League season 2023-08-14 21:54:35
ニュース BBC News - Home The Hundred 2023: England's Tammy Beaumont and Joe Root feature in plays of the day https://www.bbc.co.uk/sport/av/cricket/66502548?at_medium=RSS&at_campaign=KARANGA The Hundred England x s Tammy Beaumont and Joe Root feature in plays of the dayWatch the plays of the day from The Hundred including a record breaking score from Welsh Fire batter Tammy Beaumont and a ramp six from Joe Root of the Trent Rockets 2023-08-14 21:17:13
ビジネス ダイヤモンド・オンライン - 新着記事 雑草が飛ばす飛行機 バイオ燃料の新原料を探せ - WSJ発 https://diamond.jp/articles/-/327646 飛行機 2023-08-15 06:22:00
ビジネス ダイヤモンド・オンライン - 新着記事 ウクライナ戦争、来年に目を向け始めた西側諸国 - WSJ発 https://diamond.jp/articles/-/327647 西側諸国 2023-08-15 06:21:00
ビジネス ダイヤモンド・オンライン - 新着記事 駐ロ米大使、拘束のWSJ記者と面会3度目 - WSJ発 https://diamond.jp/articles/-/327648 面会 2023-08-15 06:18:00
ビジネス 東洋経済オンライン 「必ず後に続く」訓練で散った特攻仲間への「誓い」 待ってろ、明日には出撃命令が出るはずだ | 読書 | 東洋経済オンライン https://toyokeizai.net/articles/-/692232?utm_source=rss&utm_medium=http&utm_campaign=link_back 東洋経済オンライン 2023-08-15 06:10:00
ビジネス 東洋経済オンライン 特攻隊「と号」の教育係を命じられた下士官の覚悟 覚悟を決めよ!自分は必ずお前達の後に行く | 読書 | 東洋経済オンライン https://toyokeizai.net/articles/-/692231?utm_source=rss&utm_medium=http&utm_campaign=link_back 東洋経済オンライン 2023-08-15 06:05:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)