Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 04/16/22 in all areas

  1. Lars Fosdal

    So here's my challemge...

    Doesn't this mean that if you have two devices accessing the same database, they can create duplicate AssetKeys? I prefer to use auto incremented ID fields in the database. If I was being security minded - I would also add GUID identities per row so that it would be much harder to abuse Id values in illegitimate queries if the keys are exposed in a web or REST UI. MS SQL example CREATE TABLE [dbo].[t_company_code]( [CoyId] [int] IDENTITY(1,1) NOT NULL, [CoyCode] [nchar](3) NOT NULL [CoyCreated] [datetime] NOT NULL ) ON [PRIMARY]; GO ALTER TABLE [dbo].[t_company_code] ADD CONSTRAINT [DF_t_company_code_Created] DEFAULT (getdate()) FOR [CoyCreated]; GO CREATE TABLE [dbo].[t_assets]( [AssetId] [int] IDENTITY(1,1) NOT NULL, [CoyId] [int] NOT NULL, [Description] [nchar](63), [AssetCreated] [datetime] NOT NULL ) ON [PRIMARY]; GO ALTER TABLE [dbo].[t_assets] ADD CONSTRAINT [DF_t_Asset_Created] DEFAULT (getdate()) FOR [AssetCreated]; GO -- You would then use a view to join them CREATE VIEW [dbo].[v_CoyAssets] AS SELECT dbo.t_company_code.CoyId, dbo.t_company_code.CoyCode, dbo.t_company_code.CoyCreated, dbo.t_assets.AssetId, dbo.t_assets.Description, dbo.t_assets.AssetCreated FROM dbo.t_company_code INNER JOIN dbo.t_assets ON dbo.t_company_code.CoyId = dbo.t_assets.CoyId; GO and do a select from the view SELECT CoyCode, AssetId from v_CoyAssets order by CoyCode, AssetId;
×